mongo

package module
v2.0.0-rc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 6 Imported by: 0

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

func NewDefaultFactory(client client) trm.TrFactory

NewDefaultFactory creates default trm.Transaction(mongo.Session).

Types

type Opt

type Opt func(*Settings) error

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

type Settings struct {
	trm.Settings
	// contains filtered or unexported fields
}

Settings contains settings for mongo.Transaction.

func MustSettings

func MustSettings(trms trm.Settings, oo ...Opt) Settings

MustSettings returns Settings if err is nil and panics otherwise.

func NewSettings

func NewSettings(trms trm.Settings, oo ...Opt) (Settings, error)

NewSettings creates Settings.

func (Settings) EnrichBy

func (s Settings) EnrichBy(in trm.Settings) trm.Settings

EnrichBy fills nil properties from external 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) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL