Documentation
¶
Overview ¶
Package projection provides engine components that orchestrate the execution of projection message handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeHandler ¶
InitializeHandler initializes the state of a projection message handler.
It is called by the engine on startup, before any components are started.
Types ¶
type Compactor ¶
type Compactor struct {
// DB is the database connection used to coordinate compaction.
DB *sql.DB
// Handler is the projection to compact.
Handler dogma.ProjectionMessageHandler
// Identity is the identity of the handler.
Identity *identitypb.Identity
// Interval is the minimum time between successful compactions.
Interval time.Duration
// Timeout is the maximum time the handler is given to compact the
// projection in a single attempt.
Timeout time.Duration
// Logger is the target for log messages produced by the compactor and by
// the handler during compaction.
Logger *slog.Logger
}
Compactor periodically compacts a projection by invoking dogma.ProjectionMessageHandler.Compact().
type Consumer ¶ added in v0.2.0
type Consumer struct {
// Node is this engine's node in the cluster. Its membership determines
// which streams this node consumes.
Node *cluster.Node
// EventStreams is the catalog of event streams to consume.
EventStreams *eventstream.Catalog
// Handler is the projection message handler to which events are
// dispatched.
Handler dogma.ProjectionMessageHandler
// Identity is the identity of the handler.
Identity *identitypb.Identity
// Concurrency is the handler's concurrency preference.
Concurrency dogma.ConcurrencyPreference
// EventTypeIDs is the set of IDs of the event types that the handler
// consumes. It must not be empty.
EventTypeIDs *uuidcollection.Set
// Logger is the target for log messages produced by the consumer and its
// stream consumers.
Logger *slog.Logger
// contains filtered or unexported fields
}
Consumer dispatches events from a catalog's event streams to a projection message handler.
Each stream's workload is the responsibility of one of the live nodes in the cluster, chosen by rendezvous hashing, and that node consumes the stream. While nodes are joining or leaving, more than one node may briefly consume the same stream; the handler's optimistic concurrency control ensures each event is handled once.