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 ¶
Apply invokes the buffered effect functions in the order that they were added to this Buffer.
func (*Buffer) Cancel ¶
Cancel invokes the buffered rollback functions in the reverse of the order that they were added to this Buffer.
func (*Buffer) OnAfterCommit ¶
OnAfterCommit adds the provided effect function to set of such functions to be invoked when Buffer.Apply is called.
func (*Buffer) OnAfterRollback ¶
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)) }
func Immediate ¶
func Immediate(ctx context.Context) Controller
Immediate returns an effects.Controller that executes effects immediately upon insertion. Useful in contexts where you don't actually want to delay effect application and in tests.