Skip to main content

Components

The parts of ruststream-sqlx a service uses, one page per component: the inbox broker SqlxBroker, the queue tables it serves, the messages and headers a row hands its handler, the subscriptions and the forms they claim rows in, settlement, transactions, the context and time of a delivery, publishing and waking a subscription, the databases, the AsyncAPI document, the tests, and the transactional outbox.

The crate has two halves. The inbox keeps a task queue in a table of the service's own database: a subscription claims rows, a handler's outcome settles them, and a publish writes a row through the service's own SQL. A task can then commit in the same transaction as the data it serves. The outbox is a plugin over any RustStream broker: it records what a service publishes in a table of its own until a consumer has processed it, and publishes again at startup what was not processed. The outbox needs no inbox, and a service may use both.

Every feature is off by default and only adds to the crate. inbox turns the broker on and outbox the outbox. postgres, mysql (MySQL and MariaDB) and sqlite each add a built-in dialect and its sqlx driver. any serves an AnyPool, chrono or time the time columns, and json a headers column of JSON. testing adds the in-process mode a TestApp test connects, and the outbox's test switch. asyncapi adds the table a subscription reads to the generated document. any, chrono, time and asyncapi turn inbox on with them.

Beside the core's required traits, the broker serves batches of rows (BatchSubscriber) and lends a handler in row mode the row itself (Carries and CarriesBatch). Its default publisher is the route table, Routed, so a reply or an Out slot without a policy of its own writes a row through a route.