Documentation
¶
Overview ¶
Package synapse is a toolkit for building event-sourced systems in Go.
The library is organized as a set of small subpackages so applications import only what they need. This package itself is doc-only — there is nothing to import from it.
Core (root module, no third-party deps):
- github.com/ianunruh/synapse/es — aggregates, envelopes, the EventStore interface, the [es.Repository] (with snapshots and middleware), the codec [es.Registry], typed command handlers, [es.Execute].
- github.com/ianunruh/synapse/es/middleware — concrete repository middleware: per-aggregate locking, retry-on-conflict.
- github.com/ianunruh/synapse/es/projection — a single-process [projection.Runner] that subscribes, decodes, projects, and checkpoints. Supports type filters and batched checkpoint saves.
- github.com/ianunruh/synapse/es/commandbus — a transport-facing [commandbus.Bus] that routes named, byte-encoded commands to a typed [es.Handler], with its own middleware (Logging, Recover, Timeout).
Codecs (per-event-type, opt-in):
- github.com/ianunruh/synapse/codec/json — encoding/json adapter, root module, stdlib only.
- github.com/ianunruh/synapse/codec/proto — google.golang.org/protobuf adapter, sibling module so the protobuf dep stays out of the core.
Event, snapshot, and checkpoint store backends:
- in-memory: github.com/ianunruh/synapse/eventstore/memory, github.com/ianunruh/synapse/snapshotstore/memory, github.com/ianunruh/synapse/checkpointstore/memory — root module, suitable for tests and development.
- SQLite: github.com/ianunruh/synapse/eventstore/sqlite (and the matching snapshotstore/sqlite, checkpointstore/sqlite) — sibling modules, pure-Go via modernc.org/sqlite.
- Postgres: github.com/ianunruh/synapse/eventstore/postgres (and the matching snapshot/checkpoint variants) — sibling modules via jackc/pgx/v5.
Shared infrastructure:
- github.com/ianunruh/synapse/idgen — UUIDv7 generator.
- github.com/ianunruh/synapse/pgtest — Postgres testing harness (testcontainers-go).
- github.com/ianunruh/synapse/codec/codectest, github.com/ianunruh/synapse/eventstore/eventstoretest, github.com/ianunruh/synapse/snapshotstore/snapshotstoretest, github.com/ianunruh/synapse/checkpointstore/checkpointstoretest — shared contract test suites for the corresponding interfaces.
Architectural decisions are recorded under docs/adr/. Read the relevant ADR before relitigating a decision.
Directories
¶
| Path | Synopsis |
|---|---|
|
admin
module
|
|
|
checkpointstore
|
|
|
checkpointstorebench
Package checkpointstorebench provides a benchmark harness any implementation of es.CheckpointStore can run.
|
Package checkpointstorebench provides a benchmark harness any implementation of es.CheckpointStore can run. |
|
checkpointstoretest
Package checkpointstoretest provides a contract test suite that any implementation of es.CheckpointStore can run to verify the documented behavior.
|
Package checkpointstoretest provides a contract test suite that any implementation of es.CheckpointStore can run to verify the documented behavior. |
|
memory
Package memory provides an in-memory es.CheckpointStore suitable for tests, examples, and local development.
|
Package memory provides an in-memory es.CheckpointStore suitable for tests, examples, and local development. |
|
postgres
module
|
|
|
sqlite
module
|
|
|
codec
|
|
|
codectest
Package codectest provides a shared contract suite for es.TypedCodec implementations, mirroring the role eventstoretest plays for event stores (ADR-0018).
|
Package codectest provides a shared contract suite for es.TypedCodec implementations, mirroring the role eventstoretest plays for event stores (ADR-0018). |
|
json
Package json provides an es.TypedCodec backed by the standard library's encoding/json package.
|
Package json provides an es.TypedCodec backed by the standard library's encoding/json package. |
|
proto
module
|
|
|
Package crypto wires synapse to per-subject crypto-shredding.
|
Package crypto wires synapse to per-subject crypto-shredding. |
|
keystoretest
Package keystoretest provides a contract test suite that any implementation of crypto.KeyStore can run to verify the documented behavior.
|
Package keystoretest provides a contract test suite that any implementation of crypto.KeyStore can run to verify the documented behavior. |
|
deadletterstore
|
|
|
postgres
module
|
|
|
sqlite
module
|
|
|
Package es provides event sourcing and CQRS primitives that can be composed into application-specific aggregates, command handlers, and read models.
|
Package es provides event sourcing and CQRS primitives that can be composed into application-specific aggregates, command handlers, and read models. |
|
commandbus
Package commandbus routes named, byte-encoded commands to the typed es.Handler registered for them, so HTTP and gRPC transports can dispatch commands without writing a per-route adapter by hand.
|
Package commandbus routes named, byte-encoded commands to the typed es.Handler registered for them, so HTTP and gRPC transports can dispatch commands without writing a per-route adapter by hand. |
|
middleware
Package middleware provides built-in es.Middleware implementations for common cross-cutting concerns around command execution: per-aggregate locking, retry on transient errors, and so on.
|
Package middleware provides built-in es.Middleware implementations for common cross-cutting concerns around command execution: per-aggregate locking, retry on transient errors, and so on. |
|
process
Package process provides a thin wrapper for the process-manager pattern: an aggregate that consumes events from one or more streams and emits commands to drive a multi-step workflow.
|
Package process provides a thin wrapper for the process-manager pattern: an aggregate that consumes events from one or more streams and emits commands to drive a multi-step workflow. |
|
projection
Package projection drives consumers of the event log via a Runner that subscribes to a es.EventStore, decodes events through a codec es.Registry, invokes a es.Projection, and (optionally) checkpoints progress to a es.CheckpointStore so consumers resume across restarts.
|
Package projection drives consumers of the event log via a Runner that subscribes to a es.EventStore, decodes events through a codec es.Registry, invokes a es.Projection, and (optionally) checkpoints progress to a es.CheckpointStore so consumers resume across restarts. |
|
eventstore
|
|
|
eventstorebench
Package eventstorebench provides a benchmark harness any implementation of es.EventStore can run to measure append and load performance under standardized workloads.
|
Package eventstorebench provides a benchmark harness any implementation of es.EventStore can run to measure append and load performance under standardized workloads. |
|
eventstoretest
Package eventstoretest provides a contract test suite that any implementation of es.EventStore can run to verify the documented behavior.
|
Package eventstoretest provides a contract test suite that any implementation of es.EventStore can run to verify the documented behavior. |
|
memory
Package memory provides an in-memory es.EventStore (and es.EventStore) suitable for tests, examples, and local development.
|
Package memory provides an in-memory es.EventStore (and es.EventStore) suitable for tests, examples, and local development. |
|
postgres
module
|
|
|
sqlite
module
|
|
|
examples
|
|
|
counter
command
Command counter is an end-to-end demo of the synapse event sourcing toolkit.
|
Command counter is an end-to-end demo of the synapse event sourcing toolkit. |
|
order
command
Command order is an end-to-end demo of a richer event-sourced aggregate.
|
Command order is an end-to-end demo of a richer event-sourced aggregate. |
|
process
command
Command process is an end-to-end demo of the process-manager pattern: a Transfer aggregate that coordinates a multi-step workflow across two Account aggregates.
|
Command process is an end-to-end demo of the process-manager pattern: a Transfer aggregate that coordinates a multi-step workflow across two Account aggregates. |
|
projection
command
Command projection demonstrates the synapse subscription / projection machinery.
|
Command projection demonstrates the synapse subscription / projection machinery. |
|
Package idgen provides event identifier generators for the synapse event sourcing toolkit.
|
Package idgen provides event identifier generators for the synapse event sourcing toolkit. |
|
internal
|
|
|
testdomain
Package testdomain provides shared test fixtures — aggregates, events, commands, and a populated codec registry — for synapse's internal tests.
|
Package testdomain provides shared test fixtures — aggregates, events, commands, and a populated codec registry — for synapse's internal tests. |
|
keystore
|
|
|
memory
Package memory provides an in-memory crypto.KeyStore suitable for tests, examples, and local development.
|
Package memory provides an in-memory crypto.KeyStore suitable for tests, examples, and local development. |
|
postgres
module
|
|
|
sqlite
module
|
|
|
otel
module
|
|
|
outbox
|
|
|
nats
module
|
|
|
pgtest
module
|
|
|
snapshotstore
|
|
|
memory
Package memory provides an in-memory es.SnapshotStore suitable for tests, examples, and local development.
|
Package memory provides an in-memory es.SnapshotStore suitable for tests, examples, and local development. |
|
snapshotstorebench
Package snapshotstorebench provides a benchmark harness any implementation of es.SnapshotStore can run.
|
Package snapshotstorebench provides a benchmark harness any implementation of es.SnapshotStore can run. |
|
snapshotstoretest
Package snapshotstoretest provides a contract test suite that any implementation of es.SnapshotStore can run to verify the documented behavior.
|
Package snapshotstoretest provides a contract test suite that any implementation of es.SnapshotStore can run to verify the documented behavior. |
|
postgres
module
|
|
|
sqlite
module
|
|
|
timeoutstore
|
|
|
postgres
module
|
|
|
sqlite
module
|
Click to show internal directories.
Click to hide internal directories.