Event coordination

For a complete example, follow Checkers with the events plugin. It stores the board while sharing hand cursors, turn notifications and animation cues through temporary messages.

An application may need to tell a live consumer that an order changed or ask a worker to calculate a result. Storing every temporary message as a fact adds history that the application may never need again. Keeping all coordination elsewhere creates another service and another lifetime to manage. The events plugin connects callers of one open database inside the application process.

Durable facts and temporary messages

A publication can tell a consumer to read an order, but it cannot keep the order itself. Messages have no replay, acknowledgment or automatic retry. Information that must survive belongs in facts and transaction history. Applications store that information before publishing the related notification.

Publishing and committing remain separate operations. A commit does not automatically publish an event, and a publication does not prove that a consumer processed it. A failure between the two can leave a consumer unaware of a committed change. Applications that require reliable work delivery need a durable work record and a recovery policy.

Independent consumers

Subjects give publications names, such as orders/created, that consumers can select with complete-subject regular expressions. A notification can reach several interested consumers without choosing one of them as its destination. Each subscription has a bounded queue, and queued messages count against the database memory budget. A full queue drops that delivery and counts the loss, so a slow consumer does not stop delivery to others.

An owner gives subscriptions and exchanges a lifetime within the open database. Closing the owner ends its subscriptions and cancels its exchanges. Closing the database ends every owner and wakes waiting calls. These lifetimes let an application release temporary coordination state when its component stops.

Exchanges with one worker

Some coordination needs a reply from one worker instead of a publication to every interested consumer. An exchange connects a caller to the earliest matching live worker registration. A call fails when no worker matches. The exchange mode determines which party can send a stream.

ModeCaller sendsWorker sends
RequestOne requestOne response
PushA streamOne response after the caller finishes
PullOne requestA stream
DuplexA streamA stream

Finishing a stream closes that party's sending direction while allowing it to read remaining messages. Cancellation ends the exchange, and the other party receives a cancellation notice. A full exchange queue also cancels the exchange because losing an intermediate message would change its meaning. An exchange cannot resume after its owner or database closes.

Stored contracts

Stored event definitions describe the request and response of a route with JSON Schemas. Every exchange message must satisfy the applicable schema, and a running exchange keeps the schemas it started with. Editing a definition therefore changes later exchanges without changing an exchange already in progress. Routes without definitions remain available for messages that the application checks itself.

Definitions belong to database history even though their messages do not. Backups can carry those definitions, and opening a database that contains them requires the events plugin. This prevents an open from silently skipping their contracts. SDK generation uses the stored definitions to provide typed callers and workers.

The transport is the in-process C API and its language bindings. Separate processes need an application-owned transport before they can use these exchanges. Temporary coordination can avoid a service boundary within one application, but it supplies no durable broker or network service. Its delivery limits remain part of the application's recovery design.