Skip to content

Instantly share code, notes, and snippets.

@promontis
Last active October 31, 2019 13:09
Show Gist options
  • Save promontis/f900cf80cb6df1468cd28c2ee6ef32af to your computer and use it in GitHub Desktop.
Save promontis/f900cf80cb6df1468cd28c2ee6ef32af to your computer and use it in GitHub Desktop.

Streams

Timeline stream

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

Flow streams

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.

Resume stream (projection)

Client stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment