{"modulePath":"github.com/get-eventually/go-eventually","version":"v0.1.0-alpha.4","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package subscription\n\nPackage subscription contains Event Subscription implementations to listens and process Events coming from an Event Store, such as running Projections.\n\nChoose the Subscription type that is suited to your Event processor. Catch-up Subscriptions are the most commonly used type of Subscription, especially for Projections or Process Managers.\n\nVolatile Subscriptions might be used for volatile Projections, e.g. when process restarts should erase the previous Projection value, typical for instance summaries or metrics recording, for example.\n\n## Constants\n\n```go\nconst (\n\tDefaultPullCatchUpBufferSize = 48\n\tDefaultPullInterval          = 100 * time.Millisecond\n\tDefaultMaxPullInterval       = 1 * time.Second\n)\n```\nDefault values used by a CatchUp subscription.\n\n## Types\n\n```go\ntype CatchUp struct {\n\tSubscriptionName string\n\tTarget           stream.Target\n\tEventStore       eventstore.Streamer\n\tCheckpointer     checkpoint.Checkpointer\n\tLogger           logger.Logger\n\n\t// PullEvery is the minimum interval between each streaming call to the Event Store.\n\t//\n\t// Defaults to DefaultPullInterval if unspecified or negative value\n\t// has been provided.\n\tPullEvery time.Duration\n\n\t// MaxInterval is the maximum interval between each streaming call to the Event Store.\n\t// Use this value to ensure a specific eventual consistency window.\n\t//\n\t// Defaults to DefaultMaxPullInterval if unspecified or negative value\n\t// has been provided.\n\tMaxInterval time.Duration\n\n\t// BufferSize is the size of buffered channels used as EventStreams\n\t// by the Subscription when receiving Events from the Event Store.\n\t//\n\t// Defaults to DefaultPullCatchUpBufferSize if unspecified or a negative\n\t// value has been provided.\n\tBufferSize int\n}\n```\nCatchUp represents a catch-up subscription that uses a Streamer Event Store to process messages, by \"pulling\" new Events, compared to a CatchUp subscription, which uses a combination of streaming (pulling) and subscribing to updates.\n\n```go\nfunc (s *CatchUp) Checkpoint(ctx context.Context, event eventstore.Event) error\n```\nCheckpoint uses the Subscription Checkpointer instance to save the Global Sequence Number of the Event specified.\n\n```go\nfunc (s *CatchUp) Name() string\n```\nName is the name of the subscription.\n\n```go\nfunc (s *CatchUp) Start(ctx context.Context, eventStream eventstore.EventStream) error\n```\nStart starts sending messages on the provided EventStream channel by calling the Event Store from where it last left off.\n\n```go\ntype Subscription interface {\n\tName() string\n\tStart(ctx context.Context, eventStream eventstore.EventStream) error\n\tCheckpoint(ctx context.Context, event eventstore.Event) error\n}\n```\nSubscription represents a named subscription to Events coming from an Event Stream, usually opened from an Event Store.\n\nStarting a Subscription will open an Event Stream and start sinking messages on the provided channel.\n\nStart should be implemented as a synchronous method, which should be stopped only when either the underlying Event Store call fails, or when the context is explicitly canceled.\n\nCheckpoint should be implemented as a synchronous method, and should be called when an event has finished processing successfully. Implementations should forward the relevant event data to a Checkpointer to persist current state of the Subscription.\n\n```go\ntype Volatile struct {\n\tSubscriptionName string\n\tTarget           stream.Target\n\tLogger           logger.Logger\n\tEventStore       interface {\n\t\teventstore.Streamer\n\t\teventstore.SequenceNumberGetter\n\t}\n\n\t// PullEvery is the minimum interval between each streaming call to the Event Store.\n\t//\n\t// Defaults to DefaultPullInterval if unspecified or negative value\n\t// has been provided.\n\tPullEvery time.Duration\n\n\t// MaxInterval is the maximum interval between each streaming call to the Event Store.\n\t// Use this value to ensure a specific eventual consistency window.\n\t//\n\t// Defaults to DefaultMaxPullInterval if unspecified or negative value\n\t// has been provided.\n\tMaxInterval time.Duration\n\n\t// BufferSize is the size of buffered channels used as EventStreams\n\t// by the Subscription when receiving Events from the Event Store.\n\t//\n\t// Defaults to DefaultPullCatchUpBufferSize if unspecified or a negative\n\t// value has been provided.\n\tBufferSize int\n}\n```\nVolatile is a Subscription type that does not keep state of the last Event processed or received, nor survives the Subscription checkpoint between restarts.\n\nUse this Subscription type for volatile processes, such as projecting realtime metrics, or when you're only interested in newer events committed to the Event Store.\n\n```go\nfunc (*Volatile) Checkpoint(ctx context.Context, event eventstore.Event) error\n```\nCheckpoint is a no-op operation, since the transient nature of the Subscription does not require to persist its current state.\n\n```go\nfunc (v *Volatile) Name() string\n```\nName is the name of the subscription.\n\n```go\nfunc (v *Volatile) Start(ctx context.Context, es eventstore.EventStream) error\n```\nStart starts the Subscription by opening a subscribing Event Stream using the subscription's Subscriber instance.\n\n","path":"github.com/get-eventually/go-eventually/subscription","name":"subscription","synopsis":"Package subscription contains Event Subscription implementations to listens and process Events coming from an Event Store, such as running Projections.","isRedistributable":true}
