Skip to content
RelPrim docsAll examples

Examples

Examples

Complete, runnable RelPrim examples organized by the problem they solve. Provider failover, invalid responses, duplicate payments, Retry-After, failing dependencies and observing what happened.

The other pages describe one primitive at a time. These examples start from a problem instead, and show the smallest combination of primitives that solves it: complete code, its actual output, and what RelPrim does and does not guarantee.

Problem Example Primitives involved
A provider fails temporarily or stops responding Provider failover Retry, timeout, fallback, execution report
The provider answers successfully with unusable data Invalid response recovery Validation, retry
The same payment or order request arrives twice Idempotent payment Idempotency
The provider rejects a call and sends Retry-After Rate-limit recovery Rate-limit recovery, retry
A dependency keeps failing Circuit breaker Circuit breaker, fallback
You need to know what happened afterwards Observe an execution Execution report, structured events, OpenTelemetry, SQLite

Every example uses small local demo providers, so it runs as a single file with pip install relprim, without credentials, network access or external services. Long delays are replaced by no-op sleepers or a fake clock, so each one finishes in well under a second. Copy one into a file and run it with python.

New to RelPrim? Start with Getting started and Core concepts.

The repository’s examples/ directory contains further runnable scripts, including one per optional integration.