Documentation ¶
Overview ¶
Package manager implements a trm.Manager interface.
Index ¶
- type ChainedMW
- type Closer
- type Manager
- func (m *Manager) Do(ctx context.Context, fn func(ctx context.Context) error) (err error)
- func (m *Manager) DoWithSettings(ctx context.Context, s trm.Settings, fn func(ctx context.Context) error) (err error)
- func (m *Manager) Init(ctx context.Context, s trm.Settings) (context.Context, Closer, error)
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainedMW ¶
type ChainedMW struct {
// contains filtered or unexported fields
}
ChainedMW starts transactions in the order given and commit/rollback in reverse order.
WARNING: Rollback of last transactions isn't affected done commits. ChainedMW should be only used if the application can tolerate or recover from an inconsistent state caused by partially committed transactions.
func MustChained ¶
MustChained returns ChainedMW if err is nil and panics otherwise.
func NewChained ¶
NewChained creates *ChainedMW or chained trm.Manager.
func (*ChainedMW) DoWithSettings ¶
func (c *ChainedMW) DoWithSettings( ctx context.Context, s trm.Settings, fn func(ctx context.Context) error, ) error
DoWithSettings is an implementation of trm.Manager.
WARNING: trm.CtxKey should not be set in trm.Settings otherwise all trm.Manager would get same trm.Transaction from context.Context.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is an implementation of Manager based on storing Transaction in context.Context.
func (*Manager) DoWithSettings ¶
func (m *Manager) DoWithSettings(ctx context.Context, s trm.Settings, fn func(ctx context.Context) error) (err error)
DoWithSettings processes a transaction inside a closure with custom trm.Settings.
type Opt ¶
Opt is a type to configure Manager.
func WithCtxManager ¶
func WithCtxManager(c trm.СtxManager) Opt
WithCtxManager sets trm.Settings for Manager.
func WithSettings ¶
func WithSettings(s trm.Settings) Opt
WithSettings sets trm.Settings for Manager.