Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compensation ¶
type Compensation = func() error
Compensation is a type alias of compensating transaction function.
type Saga ¶
type Saga struct {
// contains filtered or unexported fields
}
Saga controls compensating transactions and keeps errors raised in the middle of exection.
func (*Saga) AddCompensation ¶
func (s *Saga) AddCompensation(c Compensation)
AddCompensation adds a compensating transaction to the saga. if any error has already been raised in saga, it adds nothing.
func (*Saga) Compensate ¶
func (s *Saga) Compensate()
Compensate executes compensating transactions. If no errors have been raised so far, it does nothing. The compensation transactions are executed in the reversed order of addition.
func (*Saga) Error ¶
Error returns an error raised during the saga. compensating transaction errors are wrapped inside.
func (*Saga) Errors ¶
Errors returns all errors raised during the saga, including compensating transaction errors.