mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-23 18:49:47 -05:00
@@ -1,40 +0,0 @@
|
||||
from hatchet_sdk import new_client
|
||||
from hatchet_sdk.clients.events import (
|
||||
BulkPushEventOptions,
|
||||
BulkPushEventWithMetadata,
|
||||
PushEventOptions,
|
||||
)
|
||||
|
||||
client = new_client()
|
||||
|
||||
# client.event.push("user:create", {"test": "test"})
|
||||
client.event.push(
|
||||
"user:create",
|
||||
{"test": "test"},
|
||||
options=PushEventOptions(additional_metadata={"hello": "moon"}),
|
||||
)
|
||||
|
||||
events = [
|
||||
BulkPushEventWithMetadata(
|
||||
key="event1",
|
||||
payload={"message": "This is event 1"},
|
||||
additional_metadata={"source": "test", "user_id": "user123"},
|
||||
),
|
||||
BulkPushEventWithMetadata(
|
||||
key="event2",
|
||||
payload={"message": "This is event 2"},
|
||||
additional_metadata={"source": "test", "user_id": "user456"},
|
||||
),
|
||||
BulkPushEventWithMetadata(
|
||||
key="event3",
|
||||
payload={"message": "This is event 3"},
|
||||
additional_metadata={"source": "test", "user_id": "user789"},
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
result = client.event.bulk_push(
|
||||
events, options=BulkPushEventOptions(namespace="bulk-test")
|
||||
)
|
||||
|
||||
print(result)
|
||||
@@ -0,0 +1,3 @@
|
||||
from examples.simple.worker import step1
|
||||
|
||||
step1.run()
|
||||
@@ -1,24 +1,21 @@
|
||||
from hatchet_sdk import BaseWorkflow, Context, Hatchet
|
||||
# ❓ Simple
|
||||
|
||||
from hatchet_sdk import Context, EmptyModel, Hatchet
|
||||
|
||||
hatchet = Hatchet(debug=True)
|
||||
|
||||
|
||||
class MyWorkflow(BaseWorkflow):
|
||||
@hatchet.step(timeout="11s", retries=3)
|
||||
def step1(self, context: Context) -> dict[str, str]:
|
||||
print("executed step1")
|
||||
return {
|
||||
"step1": "step1",
|
||||
}
|
||||
@hatchet.task(name="SimpleWorkflow")
|
||||
def step1(input: EmptyModel, ctx: Context) -> None:
|
||||
print("executed step1")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
wf = MyWorkflow()
|
||||
|
||||
worker = hatchet.worker("test-worker", max_runs=1)
|
||||
worker.register_workflow(wf)
|
||||
worker = hatchet.worker("test-worker", slots=1, workflows=[step1])
|
||||
worker.start()
|
||||
|
||||
|
||||
# ‼️
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user