Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer holds a set of effect and rollback functions that can be invoked as a batch with a defined order. Once either Apply or Cancel is called, all buffered effects are cleared. This type is not threadsafe. The zero-value of a Buffer is a valid state.
func (*Buffer) Apply ¶
func (b *Buffer) Apply(ctx context.Context) bool
Apply invokes the buffered effect functions in the order that they were added to this Buffer. It returns true if any effects were applied.
func (*Buffer) Cancel ¶
func (b *Buffer) Cancel(ctx context.Context) bool
Cancel invokes the buffered rollback functions in the reverse of the order that they were added to this Buffer. It returns true if any effects were canceled.
func (*Buffer) OnAfterCommit ¶
func (b *Buffer) OnAfterCommit(effect func(context.Context))
OnAfterCommit adds the provided effect function to set of such functions to be invoked when Buffer.Apply is called.
func (*Buffer) OnAfterRollback ¶
func (b *Buffer) OnAfterRollback(effect func(context.Context))
OnAfterRollback adds the provided effect function to set of such functions to be invoked when Buffer.Cancel is called.
type Controller ¶
type Controller interface {
OnAfterCommit(func(context.Context))
OnAfterRollback(func(context.Context))
}