Files
hatchet/sdks/python/examples/events/worker.py
T
Matt Kaye 752e6bd5cf Feat: Add event key to CEL env for filtering (#1748)
* feat: add event key to env

* chore: generate a bunch of stuff again

* feat: add a test for filtering by event key

* refactor: duped code

* fix: skip flaky test in ci

* Fix: Add filter payloads to context (#1743)

* feat: add payload to ctx

* chore: ver

* fix: add filter payload to go

* fix: tests + lint

* fix: lint

* fix: naming
2025-05-19 12:52:41 -04:00

36 lines
649 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()