Totem is an event sourcing framework framed as a timeline. Other event sourcing implementations tend to emit to individual streams, as opposed to the one common stream. The main tradeoff between this is that of total order VS contention. The timeline stream has a total order for all of the events in an area. This can be of use when an order is needed over the topics within an area. The downside of such one common stream is that of contention; many events need to write to that one and single stream.
There is one timeline stream per area
and it is the single source of truth for an area.
An event on this stream contains a 'value' (the payload of the event) and 'metadata'. The metadata contains several interesting fields:
- cause
- topic
- routeTypes
- routeIds
TODO: describe the fields in more detail
There are two types of flows: topic
and query
. A flow has two streams: -checkpoint
and -routes
.
Checkpoint stream
A flow progresses along a timeline. For each event handled it writes its progression to the checkpoint stream, containing both the internal state of the flow and metadata for its position on the timeline.
TODO: is the position of the metadata used, or is it just metadata?
Routes stream
For EventStore this is an implicit stream using the projection indexing feature.
The routes stream is projected from events of the timeline
stream. One of the advantages of the routes stream is that it tells exactly which flows have pending work. If we didn't have it, the timeline would have to look at every flow that exists, then examine the entire timeline in the future to determine which flows had been routed to, since the events on timeline have the route metadata. This would require bookkeeping of the full set of flows.