mongodb

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundContextStrategy

type BackgroundContextStrategy struct {
	// contains filtered or unexported fields
}

BackgroundContextStrategy is the ContextStrategy implementation that always returns Background context and noop cancel

func NewBackgroundContextStrategy

func NewBackgroundContextStrategy() *BackgroundContextStrategy

NewBackgroundContextStrategy instantiates new BackgroundContextStrategy

func (*BackgroundContextStrategy) Append

Append is the ContextStrategy.Append() implementation

func (*BackgroundContextStrategy) CountEventsFor

CountEventsFor is the ContextStrategy.CountEventsFor() implementation

func (*BackgroundContextStrategy) CreateIndices

CreateIndices is the ContextStrategy.CreateIndices() implementation

func (*BackgroundContextStrategy) FromVersion

FromVersion is the ContextStrategy.FromVersion() implementation

func (*BackgroundContextStrategy) GetEventsFor

GetEventsFor is the ContextStrategy.GetEventsFor() implementation

type ContextStrategy

type ContextStrategy interface {
	Append() (context.Context, context.CancelFunc)
	GetEventsFor() (context.Context, context.CancelFunc)
	FromVersion() (context.Context, context.CancelFunc)
	CountEventsFor() (context.Context, context.CancelFunc)
	CreateIndices() (context.Context, context.CancelFunc)
}

ContextStrategy is an interface that represents strategy for providing contexts for corresponding MongoDB EventStore instance queries to MongoDB

type EventStore

type EventStore struct {
	// contains filtered or unexported fields
}

EventStore The mongodb event store

func NewEventStore

func NewEventStore(mongoDB *mongo.Database, registry goengine.TypeRegistry, options ...Option) *EventStore

NewEventStore creates new MongoDB based event store

func (*EventStore) Append

func (s *EventStore) Append(events *goengine.EventStream) error

Append adds an event to the event store

func (*EventStore) CountEventsFor

func (s *EventStore) CountEventsFor(streamName goengine.StreamName, id string) (int64, error)

CountEventsFor counts events for an id on the specified stream

func (*EventStore) FromVersion

func (s *EventStore) FromVersion(streamName goengine.StreamName, id string, version int) (*goengine.EventStream, error)

FromVersion gets events for an id and version on the specified stream

func (*EventStore) GetEventsFor

func (s *EventStore) GetEventsFor(streamName goengine.StreamName, id string) (*goengine.EventStream, error)

GetEventsFor gets events for an id on the specified stream

type MongoEvent

type MongoEvent struct {
	ID         string    `bson:"aggregate_id,omitempty"`
	Version    int       `bson:"version"`
	Type       string    `bson:"type"`
	Payload    string    `bson:"payload"`
	RecordedOn time.Time `bson:"recorded_on"`
}

MongoEvent represents an event on mongodb

type Option

type Option func(eventStore *EventStore)

Option is the options type to configure MongoDB EventStore implementation creation

func ContextBackground

func ContextBackground() Option

ContextBackground sets Context Strategy for EventStore to BackgroundContextStrategy

func ContextTimeout

func ContextTimeout(options ...TimeoutContextStrategyOption) Option

ContextTimeout sets Context Strategy for EventStore to TimeoutContextStrategy

type TimeoutContextStrategy

type TimeoutContextStrategy struct {
	// contains filtered or unexported fields
}

TimeoutContextStrategy is the ContextStrategy implementation that returns configurable WithTimeout context and its cancel

func NewTimeoutContextStrategy

func NewTimeoutContextStrategy(options ...TimeoutContextStrategyOption) *TimeoutContextStrategy

NewTimeoutContextStrategy instantiates new TimeoutContextStrategy

func (*TimeoutContextStrategy) Append

Append is the ContextStrategy.Append() implementation

func (*TimeoutContextStrategy) CountEventsFor

func (s *TimeoutContextStrategy) CountEventsFor() (context.Context, context.CancelFunc)

CountEventsFor is the ContextStrategy.CountEventsFor() implementation

func (*TimeoutContextStrategy) CreateIndices

CreateIndices is the ContextStrategy.CreateIndices() implementation

func (*TimeoutContextStrategy) FromVersion

FromVersion is the ContextStrategy.FromVersion() implementation

func (*TimeoutContextStrategy) GetEventsFor

GetEventsFor is the ContextStrategy.GetEventsFor() implementation

type TimeoutContextStrategyOption

type TimeoutContextStrategyOption func(s *TimeoutContextStrategy)

TimeoutContextStrategyOption is the options type to configure TimeoutContextStrategy creation

func NewAppendTimeout

func NewAppendTimeout(timeout time.Duration) TimeoutContextStrategyOption

NewAppendTimeout is the TimeoutContextStrategy configuration option to set a timeout for Append call

func NewCountEventsForTimeout

func NewCountEventsForTimeout(timeout time.Duration) TimeoutContextStrategyOption

NewCountEventsForTimeout is the TimeoutContextStrategy configuration option to set a timeout for CountEventsFor call

func NewCreateIndicesTimeout

func NewCreateIndicesTimeout(timeout time.Duration) TimeoutContextStrategyOption

NewCreateIndicesTimeout is the TimeoutContextStrategy configuration option to set a timeout for CreateIndices call

func NewFromVersionTimeout

func NewFromVersionTimeout(timeout time.Duration) TimeoutContextStrategyOption

NewFromVersionTimeout is the TimeoutContextStrategy configuration option to set a timeout for FromVersion call

func NewGetEventsForTimeout

func NewGetEventsForTimeout(timeout time.Duration) TimeoutContextStrategyOption

NewGetEventsForTimeout is the TimeoutContextStrategy configuration option to set a timeout for GetEventsFor call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL