mongo

package
v0.0.0-...-eeebc8f Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// InitialPositionTrimHorizon is a constant that indicates a tracker starts at the beginning of time
	InitialPositionTrimHorizon = int64(-2)

	// InitialPositionEdge indicates a tracker starts at the most recent event and works forward
	InitialPositionEdge = int64(-1)
)

Variables

This section is empty.

Functions

func CreateOpLogPublisherFromSession

func CreateOpLogPublisherFromSession(session *mgo.Session, options OplogOptions) (func() error, error)

CreateOpLogPublisherFromSession creates a new publisher that consumes events from a MongoDB oplog and propegates them to a target. This version allows BYO sessions.

func CreateOplogPublisher

func CreateOplogPublisher(dialURL string, options OplogOptions) (func() error, error)

CreateOplogPublisher creates a new publisher that consumes events from a MongoDB oplog and propegates them to a target.

func NewStore

func NewStore(endpoint Endpoint) (eventsourcing.EventStore, error)

NewStore creates a new MongoDB backed event store for an application to use.

func NewStoreWithConnection

func NewStoreWithConnection(session *mgo.Session, collection *mgo.Collection) (eventsourcing.EventStore, error)

NewStoreWithConnection creates a new MGO-backed store with a specific session and collection. The collection is used to store the records, the session is used to clean up afterward.

Types

type Endpoint

type Endpoint struct {
	DialURL        string `json:"dial_url"`        // DialURL is the mgo URL to use when connecting to the cluster
	DatabaseName   string `json:"database_name"`   // DatabaseName is the database to create/connect to.
	CollectionName string `json:"collection_name"` // CollectionName is the collection name to put new documents in to
}

Endpoint are parameters for the MongoDB event store to use when initializing.

type InitialPosition

type InitialPosition int64

InitialPosition of the tracker

type OplogOptions

type OplogOptions struct {
	TargetDatabase string                       // TargetDatabase is the database to read
	CollectionName string                       // Collection name
	Publisher      eventsourcing.EventPublisher // Event publisher
	Registry       eventsourcing.EventRegistry  // Event registry
	Tracker        ProgressTracker              // Progress tracker
}

OplogOptions contains the options for tailing an oplog.

type ProgressTracker

type ProgressTracker interface {
	// StartPosition fetches the initial offset to tail from the log
	StartPosition() (int64, error)

	// UpdatePosition sets the target position for an Oplog tailer.
	UpdatePosition(int64) error
}

ProgressTracker is an interface that describes a mechanism that stores the current progress of an OpLog follower and logs progress.

func CreateTracker

func CreateTracker(endpoint Endpoint, key string, initialPosition int64) (ProgressTracker, error)

CreateTracker creates a new MongoDB backed oplog tracker

func CreateTrackerWithConnection

func CreateTrackerWithConnection(session *mgo.Session, collection *mgo.Collection, key string, initialPosition int64) (ProgressTracker, error)

CreateTrackerWithConnection creates a new MGO-backed tracker with a specific connection and collection. Clients assume shutdown responsibility.

Jump to

Keyboard shortcuts

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