Skip to main content

Examples

Each example is self-contained and runnable. Required env vars are listed in the example's README.

#ExampleDemonstrates
01minimumBare minimum that runs (one action, one derived NATS ingress)
02required_vs_optionalservice-first Service("name", ...), canonical HTTP ingress, and narrow TriggersSettings(...) override examples
03multiple_actionsMultiple actions with distinct retry configs
04multi_sourceNATS + Kafka + HTTP ingress together, using the default canonical HTTP path and optional public-base override
05error_handlingPermanentError, SkipForward, retry exhaustion
06with_dedup_redisRedis-backed app-level dedup via enable_dedup()
07with_rate_limit_redisRedis-backed rate limit via enable_rate_limit()
08observabilitystructlog + Prom /metrics + OTel tracing
09testing_with_harnesspytest + Harness end-to-end
10production_shapeProduction-typical metadata with runtime wiring coming straight from TRIGGERS_* env
11flow_labLocal E2E dummy with result_event, condition/mapping/rate-limit support, and service-first wiring

Running examples

Examples are documentation, not installable packages. They expect the SDK to be installed in the active environment (e.g. pip install -e ../.. from the repo root, or make install from triggers-sdk-python/).

Most examples require a local NATS at nats://127.0.0.1:4222. Start one via:

docker run -p 4222:4222 nats:2.10-alpine -js

Examples that need Kafka, Redis, or an HTTP listener call that out explicitly in their own README.

Example 11_flow_lab demonstrates result_event catalog metadata for Studio action→action chaining. See its README for local stack usage; the Go twin lives at triggers-sdk-go/examples/flow_lab/.

Smoke check

Each service.py is verified by an import-only smoke check (no runtime broker needed):

cd examples/<N>_<name>
python -c "import service; print(service.svc.name)"

The examples are also covered by examples/test_examples_surface.py, which checks the approved public API surface, canonical derived ingress names, and example-specific manifest details.

The runtime behavior is exercised by the SDK's own unit + harness + interop tests; the examples exist to teach the public API surface.