mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-31 13:49:48 -06:00
* feat: snippets * feat: first couple paragraphs * feat: flesh out hatchet examples * fix: one more * feat: log view * fix: cleanup * feat: another section * fix: fmt * feat: debugging section * fix: proofread * fix: lint * chore: gen * fix: copilot * fix: copilot * feat: add blog post link * fix: feedback * chore: sdk ver * chore: gen * fix: ugh
35 lines
644 B
Python
35 lines
644 B
Python
from pydantic import BaseModel
|
|
|
|
from hatchet_sdk import Context, Hatchet
|
|
|
|
hatchet = Hatchet()
|
|
EVENT_KEY = "user:create"
|
|
SECONDARY_KEY = "foobarbaz"
|
|
|
|
|
|
class EventWorkflowInput(BaseModel):
|
|
should_skip: bool
|
|
|
|
|
|
# > Event trigger
|
|
event_workflow = hatchet.workflow(
|
|
name="EventWorkflow",
|
|
on_events=[EVENT_KEY, SECONDARY_KEY],
|
|
input_validator=EventWorkflowInput,
|
|
)
|
|
|
|
|
|
@event_workflow.task()
|
|
def task(input: EventWorkflowInput, ctx: Context) -> None:
|
|
print("event received")
|
|
|
|
|
|
def main() -> None:
|
|
worker = hatchet.worker(name="EventWorker", workflows=[event_workflow])
|
|
|
|
worker.start()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|