Event coordination
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 queue that uses the plugin allocator, with no configured size or count limit. Resident queues do not count against limits.memory-bytes, which bounds each runtime. If the process cannot allocate a queued message, that delivery is dropped and counted.
A subscription lives as long as the request that opened it. Cancelling that request ends the subscription and frees its queue, and closing the database ends every open request. The same rule holds for a worker and for each side of an exchange, so an application releases temporary coordination state by ending the requests of the component that 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.
| Mode | Caller sends | Worker sends |
|---|---|---|
| Request | One request | One response |
| Push | A stream | One response after the caller finishes |
| Pull | One request | A stream |
| Duplex | A stream | A 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. Failure to queue an exchange notice cancels the exchange because losing an intermediate message would change its meaning. An exchange cannot resume after its request or database ends.
Handlers the database runs
Some consumers belong to the database rather than to a connected component. A saved namespace can declare a subscription whose function the database runs for each matching publication, before the publish returns, and a responder whose function's value answers each matching request. Their functions are ordinary DUST: they can write, publish and call. A write that wants to announce itself publishes from its on {commit …} body, because a message cannot be taken back if the write rolls back. A failed subscription never undoes the publication; the publisher sees the failure and the publication stands.
The CPU budget covers the whole publication and its saved-handler chain. Each expression keeps its own runtime memory limit.
Messages carry no stored contract. A subscription or responder checks what it receives with the same schema functions as any other DUST code. Only the declarations are database state: they travel with the namespaces that hold them, through history and backups, and opening a database whose namespaces use them requires the events plugin.
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.