Documentation
¶
Overview ¶
Package persistence defines the interfaces Ax uses to persist data.
Index ¶
- func BeginTx(ctx context.Context) (Tx, Committer, error)
- func GetOrBeginTx(ctx context.Context) (Tx, Committer, error)
- func WithDataStore(parent context.Context, ds DataStore) context.Context
- func WithTx(parent context.Context, tx Tx) context.Context
- type Committer
- type DataStore
- type InboundInjector
- type OutboundInjector
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrBeginTx ¶
GetOrBeginTx returns the transaction stored in ctx, or starts a new one if ctx does not contain a transaction.
If a new transaction is started, the caller is said to "own" the transaction, that is, the caller is responsible for committing the transaction.
If ctx already contains a transaction, the caller is said to "participate" in the transaction, but is not responsible for committing. In this case, the returned Committer is configured such that Commit() and Rollback() are no-ops that always return nil.
func WithDataStore ¶
WithDataStore returns a new context derived from parent that contains a DataStore.
The data store can be retrieved from the context with GetDataStore().
Types ¶
type Committer ¶
type Committer interface { // Commit applies the changes to the data store. Commit() error // Rollback discards the changes without applying them to the data store. Rollback() error }
Committer is an interface used to commit and rollback persistence transactions.
type DataStore ¶
type DataStore interface { // BeginTx starts a new transaction. BeginTx(ctx context.Context) (Tx, Committer, error) }
DataStore is an interface for accessing a transactional data store.
type InboundInjector ¶
type InboundInjector struct { DataStore DataStore Next endpoint.InboundPipeline }
InboundInjector is an implementation of endpoint.InboundPipeline that injects a data store into the context.
func (*InboundInjector) Accept ¶
func (i *InboundInjector) Accept( ctx context.Context, s endpoint.MessageSink, env endpoint.InboundEnvelope, ) error
Accept calls i.Next.Accept() with a context derived from ctx and containing i.DataStore.
func (*InboundInjector) Initialize ¶
Initialize is called during initialization of the endpoint, after the transport is initialized. It can be used to inspect or further configure the endpoint as per the needs of the pipeline.
type OutboundInjector ¶
type OutboundInjector struct { DataStore DataStore Next endpoint.OutboundPipeline }
OutboundInjector is an implementation of endpoint.OutboundPipeline that injects a data store into the context.
func (*OutboundInjector) Accept ¶
func (i *OutboundInjector) Accept( ctx context.Context, env endpoint.OutboundEnvelope, ) error
Accept calls i.Next.Accept() with a context derived from ctx and containing i.DataStore.
func (*OutboundInjector) Initialize ¶
Initialize is called during initialization of the endpoint, after the transport is initialized. It can be used to inspect or further configure the endpoint as per the needs of the pipeline.
type Tx ¶
type Tx interface { // DataStore returns the DataStore that the transaction operates on. DataStore() DataStore }
Tx represents an atomic unit-of-work performed on a DataStore.
func GetTx ¶
GetTx returns the transaction stored in ctx.
If ctx does not contain a transaction then ok is false.
Transactions are made available via the context so that application-defined message handlers can optionally perform some additional storage operations within the same transaction as infrastructure features such as the outbox system.