Example Contracts¶
This section provides ready-to-use Pacto contracts for common infrastructure services. Use these as references when writing your own contracts, or as dependencies. New to authoring? Start with the developer guide.
For a complete, runnable demo, see the live dashboard demo — its source and curated contract set live in examples/demo.
Tip
These contracts represent the operational interface of each service — not a deployment recipe. They describe what a service exposes and how it behaves — not how to deploy it. Each one composes schemas you already have — Protocol Buffers for gRPC APIs, JSON Schema for configurations — rather than inventing a new format; the contract is the relational layer Pacto adds around them: ownership, dependencies, compatibility, lifecycle.
Available examples¶
| Service | Type | State | Description |
|---|---|---|---|
| PostgreSQL | service | stateful/persistent | Relational database |
| Redis | service | stateful/persistent | In-memory data store |
| RabbitMQ | service | stateful/persistent | Message broker |
| NGINX | service | stateless/ephemeral | Reverse proxy / web server |
| Cron Worker | scheduled | stateless/ephemeral | Scheduled batch job |
| Event Processor | service | stateless/ephemeral | Event-driven message consumer |
| gRPC Service | service | stateless/ephemeral | gRPC microservice with Proto contract |
| Hybrid Cache API | service | hybrid/persistent | API with local cache and upstream rebuild |
Using examples as dependencies¶
A JSON Schema or .proto describes one interface in isolation; wiring these contracts together as dependencies — with compatibility ranges — is Pacto describing the relationships between interfaces and how they change.
You can reference these contracts (once published to a registry) as dependencies in your own pacto.yaml:
dependencies:
- name: postgres
ref: oci://ghcr.io/acme/postgres-pacto@sha256:abc1230000000000000000000000000000000000000000000000000000000000
required: true
compatibility: "^16.0.0"
- name: redis
ref: oci://ghcr.io/acme/redis-pacto@sha256:def4560000000000000000000000000000000000000000000000000000000000
required: false
compatibility: "^7.0.0"
See the contract reference for the full dependency schema.
Then use pacto graph to visualize the full dependency tree: