mongodb

package
v0.0.0-...-ed9d917 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMongoSession

func CreateMongoSession(ctx context.Context, session mongo.Session) saga.Session

func CreateMongoStore

func CreateMongoStore(client *mongo.Client, database string, collection string, options ...func(mongoStore *MongoStore) error) (saga.Store, error)

func ExpireInSeconds

func ExpireInSeconds(seconds int32) func(*MongoStore) error

Types

type Index

type Index struct {
	Name             string `bson:"name"`
	ExpiresInSeconds *int32 `bson:"expiresInSeconds,omitempty"`
}

type MongoSession

type MongoSession struct {
	mongo.Session
	context.Context
}

func (*MongoSession) Close

func (session *MongoSession) Close()

func (*MongoSession) Commit

func (session *MongoSession) Commit() error

type MongoStore

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

func (*MongoStore) CompleteSaga

func (store *MongoStore) CompleteSaga(session saga.Session, correlationId string, sagaType string) error

func (*MongoStore) CreateSaga

func (store *MongoStore) CreateSaga(correlationId string, sagaType string) error

Create a new saga with the given correlationId and sagaType in the MongoStore

func (*MongoStore) DeleteSaga

func (store *MongoStore) DeleteSaga(correlationId string, sagaType string) error

func (*MongoStore) RequestSaga

func (store *MongoStore) RequestSaga(correlationId string, sagaType string) (*saga.Context, error)

Request a saga from the MongoDB store and put a transaction lock on the saga. If an error occurs, the session will be closed and all transactions will be dismissed.

func (*MongoStore) SagaExists

func (store *MongoStore) SagaExists(correlationId string, sagaType string) (bool, error)

func (*MongoStore) UpdateState

func (store *MongoStore) UpdateState(session saga.Session, correlationId string, sagaType string, state map[string]interface{}) error

type Saga

type Saga struct {
	ID            primitive.ObjectID     `bson:"_id"`
	CorrelationID string                 `bson:"correlationId"`
	Type          string                 `bson:"type"`
	State         map[string]interface{} `bson:"state"`
	IsCompleted   bool                   `bson:"isCompleted"`
	LockTime      *time.Time             `bson:"lockTime,omitempty"`
	CreatedAt     time.Time              `bson:"createdAt"`
}

Jump to

Keyboard shortcuts

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