Repository navigation
Concepts
Cloud Streams captures cloud events, stores them durably and in order, and delivers them to subscribers. This page explains the few concepts everything else builds on.
A cloud event is an event in the CloudEvents format: context attributes, such as id, source, type, subject and time, extensions, and data. Cloud Streams only handles cloud events, in version 1.0 of the specification.
-
Publishing: publishers post cloud events to a gateway's ingestion endpoint,
POST /api/events/pub, in any content mode of the HTTP binding: structured, binary or batched (see Ingestion). Gateways also consume them from Kafka, NATS, AMQP, SQS, Pub/Sub, Service Bus and PostgreSQL feeds (see Transports). - Admission: before storing an event, the gateway validates it, authorizes its publisher, and checks it against its schema and the gateway's policies (see Ingestion).
curl -X POST http://localhost:8080/api/events/pub \
-H 'Content-Type: application/cloudevents+json' \
-d '{ "specversion": "1.0", "id": "1", "source": "https://orders.example.com", "type": "order.placed", "subject": "order-1", "data": { "total": 42 } }'Stored cloud events form a stream: an ordered, append-only sequence, in which each event has an offset, its position from 0.
- Durability: events are stored in KurrentDB before the gateway answers the publisher. They are never modified afterwards, and only removed by a retention policy (see Retention).
- Namespaces: each namespace has a stream of its own, which only its gateways write to and its subscriptions read from.
- Reading: streams are read forwards or backwards, from an offset or a point in time, through the API and the dashboard (see Operations).
Every stored event is also indexed into partitions: sub-streams of the events that share the value of an attribute. A subscription, or a reader, that only cares about some events reads their partition rather than the whole stream.
| Partition type | Events that share their |
|---|---|
by-source |
source |
by-type |
type |
by-subject |
subject |
by-correlation-id |
correlation id, resolved by the gateway's metadata configuration |
by-causation-id |
causation id, resolved by the gateway's metadata configuration |
A partition is identified by its type and its id, the shared value, e.g. by-source and https://orders.example.com. Offsets within a partition are its own, from 0.
GET /api/resources/v1/namespaces/{namespace}/cloudevents/partitions/{type} lists the ids of the partitions of a type (by-source, by-type, by-subject, by-correlation-id, by-causation-id), sorted case-insensitively, page by page (maxResults, up to 1000, and continuationToken), optionally filtered by a case-insensitive prefix. Partitions belong to the namespace the path names.
Partition ids are kept in an index in Redis, updated as events are ingested, so that listing and searching them never loads them all.
By default, events are kept forever. A retention policy makes them expire once they are older than a maximum age, or beyond a maximum count of the latest ones:
Retention: # e.g. Retention__MaxAge=P30D
MaxAge: P30D # an ISO 8601 duration
MaxCount: 1000000-
How it's applied. Gateways apply the policy at startup, as KurrentDB's
$maxAgeand$maxCountmetadata of thecloud-eventsstream, and KurrentDB enforces it.- The policy belongs to the stream, which every gateway shares: configure the same one on every gateway.
- An application without a policy leaves the current one as it is. Setting both values to
0removes it.
- Expired events can no longer be read, by subscriptions or otherwise, and are removed from disk when KurrentDB is scavenged. Until then, loosening the policy makes them readable again.
- Partitions skip the events that expired.
-
Offsets don't change: the stream's metadata (
GET /api/resources/v1/namespaces/{namespace}/cloudevents/stream, or/api/resources/v1/cloudevents/streamfor the whole stream) reports the policy andfirstOffset, the offset of the first event retained. Partitions report their ownfirstOffset. -
Subscriptions behind the retained range never receive the events that expired. They resume with the first one retained:
- the broker logs a warning with the offsets they missed;
- the subscription health endpoint reports them as
expiredEvents; - the dashboard warns on the subscription's page.
Cloud Streams is configured with declarative resources, in the manner of Kubernetes objects: each has metadata, a spec describing what it should be, and a status reporting what it is. They're managed with the API, the dashboard, or, in Kubernetes mode, kubectl and any GitOps tool, as custom resources of the cloud-streams.io/v1 group.
| Kind | What it is |
|---|---|
Namespace |
an isolated tenant, with its own stream, resources and secrets. In Kubernetes mode, a labelled Kubernetes namespace (see Namespaces) |
Gateway |
the service that ingests cloud events, and how it admits them: authorization, validation, ingestion policies and feeds (see Ingestion) |
Broker |
the service that delivers the subscriptions of its namespace, and how it delivers them by default (see Delivery) |
Subscription |
which events to deliver, where, and how (see Subscriptions) |
Sink |
an endpoint, and how to authenticate to it, that subscriptions deliver to by name (see Transports) |
Feed |
an endpoint that gateways consume cloud events from by name (see Transports) |
Schema |
a versioned JSON schema, which the data of cloud events is validated against (see Ingestion) |
| Component | Role |
|---|---|
| Gateway | Ingests cloud events: over HTTP, and from its feeds. It also serves the management API, the dashboard and the MCP endpoint, unless turned off |
| Broker | Delivers the subscriptions of its namespace, with retries, dead letters and offsets. Replicas share subscriptions |
| Operator | In Kubernetes mode only: deploys gateways and brokers from their resources, validates resources, and manages the CRDs |
| KurrentDB | Stores the cloud events, their streams and partitions |
| Redis | Stores the resources in the default Redis mode, and, in every mode, the partition index, deduplication keys, rate limits and the leases of subscriptions |