saga

package
v0.0.0-...-a50e536 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Def

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

Def defines a saga type

func (*Def) HandleEvent

func (sd *Def) HandleEvent(exchange, topic string, event gbus.Message, handler gbus.MessageHandler) error

HandleEvent implements HandlerRegister interface

func (*Def) HandleMessage

func (sd *Def) HandleMessage(message gbus.Message, handler gbus.MessageHandler) error

HandleMessage implements HandlerRegister interface

func (*Def) String

func (sd *Def) String() string

type Glue

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

Glue ties the incoming messages from the Bus with the needed Saga instances

func NewGlue

func NewGlue(bus gbus.Bus, sagaStore Store, svcName string) *Glue

NewGlue creates a new Sagamanager

func (*Glue) RegisterSaga

func (imsm *Glue) RegisterSaga(saga gbus.Saga, conf ...gbus.SagaConfFn) error

RegisterSaga registers the saga instance with the Bus

type Instance

type Instance struct {
	ID                 string
	ConcurrencyCtrl    int
	UnderlyingInstance gbus.Saga
	MsgToMethodMap     []*MsgToFuncPair
}

Instance represent a living instance of a saga of a particular definition

func NewInstance

func NewInstance(sagaType reflect.Type, msgToMethodMap []*MsgToFuncPair, confFns ...gbus.SagaConfFn) *Instance

func (*Instance) String

func (si *Instance) String() string

type MsgToFuncPair

type MsgToFuncPair struct {
	Filter       *gbus.MessageFilter
	SagaFuncName string
}

type Store

type Store interface {
	RegisterSagaType(saga gbus.Saga)
	GetSagaByID(tx *sql.Tx, sagaID string) (*Instance, error)
	GetSagasByType(tx *sql.Tx, sagaType reflect.Type) ([]*Instance, error)
	SaveNewSaga(tx *sql.Tx, sagaType reflect.Type, newInstance *Instance) error
	UpdateSaga(tx *sql.Tx, instance *Instance) error
	DeleteSaga(tx *sql.Tx, instance *Instance) error
	Purge() error
}

Store abtracts the way sagas get persisted

type TimeoutManager

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

TimeoutManager manages timeouts for sagas TODO:Make it persistent

func (*TimeoutManager) RequestTimeout

func (tm *TimeoutManager) RequestTimeout(svcName, sagaID string, duration time.Duration)

RequestTimeout requests a timeout from the timeout manager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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