Skip to main content

Crate bus_contract_journal

Crate bus_contract_journal 

Expand description

§bus-contract-journal

The journal contract of bus-contract: events of journaled points kept with a number, read again from one, delivered after the publisher has moved on.

bus-contract is a small core (points, order, alter and collect, requests, local listeners, introspection) plus optional capabilities. Each capability is its own contract, published as its own crate and versioned on its own, so a change to one does not break the users of the others.

§Use

use std::sync::Arc;
use bus_contract_journal::BusJournal;

/// Whether the bus offers the journal capability.
fn has_journal(bus: &Arc<dyn bus_contract::Bus>) -> bool {
    bus.journal().is_some()
}
  • BusJournal gives bus.journal() on any bus: dyn Bus, Arc<dyn Bus> or a concrete one. It returns None when the bus does not offer the capability.
  • The contract’s items live here: Journal, JournalEntry, Since, Origin, kind_matches, the CONTRACT, the JOURNALED facet with is_journaled, and check / not_journaled for implementations.

§Status: owns its contract since 0.2

Since 0.2, with bus-contract 0.5, the items above are defined here, not in the core. The core names no capability: it keeps the typed lookup (Bus::capability), the Contract and Facet types, and offers. BusJournal reaches the capability through that lookup only.

Upgrading from 0.1 and bus-contract 0.4: import the items from bus_contract_journal and add use bus_contract_journal::BusJournal; where bus.journal() is called. Every rename is in MIGRATION-0.5.md.

§Guarantees

What a bus offering this capability guarantees, and what it does not, property by property with stable ids, is the journal section of GUARANTEES.md. Each property names the bus-kernel conformance check that proves it.

§Versions

Released on its own, with its own CHANGELOG. Needs bus-contract 1. See RELEASING.md for the repository’s crates and their publish order.

§License

MIT or Apache-2.0, at your option.

Structs§

JournalEntry
One event of a journal: what happened, its number, what caused it.
Journaled
The data of the JOURNALED facet.
Origin
Who sent what crosses a process boundary: the far side of a link, as the receiving side knows it.
Since
What a read of a journal after a number found (Journal::since).

Constants§

CONTRACT
The journal contract: a bus offers it by answering for dyn Journal in Bus::capability. A point that is journaled says so with the JOURNALED facet, which needs this contract.
JOURNALED
The facet of a journaled event point: its events go through the bus’s journal, published with a number and delivered to the listeners in journal order after the publisher has moved on (PointDecl::of::<P>(…).facets(&[JOURNALED]), or PointSpec::new(…).facet(JOURNALED)). Only an event point is journaled (check).

Traits§

BusJournal
Reaches the Journal capability of any bus: bus.journal().
Journal
A capability of a bus (BusJournal::journal): events kept in order with a number, read again from a number, and delivered to their point’s listeners after the publisher has moved on.

Functions§

check
What the journal contract refuses in a declaration, for an implementation’s declare_point: a journaled point that is not an event (Refused::Contract).
is_journaled
Whether facets (PointSpec::facets, PointInfo::facets) mark the point journaled.
kind_matches
Whether the event kind kind matches pattern: the same id, or a prefix ending in .* (vault.* matches vault.changed), or * for every kind. Every implementation reads patterns this way.
not_event
The refusal of a journaled point that is not an event.
not_journaled
The refusal of a publish on a point not declared journaled on this bus (Journal::publish_any); nothing was recorded.