Documentation ¶
Overview ¶
Package mongo is an implementation of trm.Transaction interface by Transaction for mongo.Client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultFactory ¶
NewDefaultFactory creates default trm.Transaction(mongo.Session).
Types ¶
type Opt ¶
Opt is a type to configure Settings.
func WithSessionOpts ¶
func WithSessionOpts(opts *options.SessionOptions) Opt
WithSessionOpts sets up options.SessionOptions for the Settings.
func WithTransactionOpts ¶
func WithTransactionOpts(opts *options.TransactionOptions) Opt
WithTransactionOpts sets up options.TransactionOptions for the Settings.
type Settings ¶
Settings contains settings for mongo.Transaction.
func MustSettings ¶
MustSettings returns Settings if err is nil and panics otherwise.
func NewSettings ¶
NewSettings creates Settings.
func (Settings) SessionOpts ¶
func (s Settings) SessionOpts() *options.SessionOptions
SessionOpts returns *options.SessionOptions for the trm.Transaction.
func (Settings) TransactionOpts ¶
func (s Settings) TransactionOpts() *options.TransactionOptions
TransactionOpts returns trm.CtxKey for the trm.Transaction.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is trm.Transaction for mongo.Client.
func NewTransaction ¶
func NewTransaction( ctx context.Context, sessionOptions *options.SessionOptions, trOpts *options.TransactionOptions, client client, ) (context.Context, *Transaction, error)
NewTransaction creates trm.Transaction for mongo.Client.
func (*Transaction) Closed ¶ added in v1.5.0
func (t *Transaction) Closed() <-chan struct{}
Closed returns a channel that's closed when transaction committed or rolled back.
func (*Transaction) Commit ¶
func (t *Transaction) Commit(ctx context.Context) error
Commit the trm.Transaction.
func (*Transaction) IsActive ¶
func (t *Transaction) IsActive() bool
IsActive returns true if the transaction started but not committed or rolled back.
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback(ctx context.Context) error
Rollback the trm.Transaction.
func (*Transaction) Transaction ¶
func (t *Transaction) Transaction() interface{}
Transaction returns the real transaction mongo.Session.