Documentation ¶
Overview ¶
Package goredis8 is an implementation of trm.Transaction interface by Transaction for redis.UniversalClient.
Index ¶
- Constants
- Variables
- func NewDefaultFactory(db redis.UniversalClient) trm.TrFactory
- type Cmdable
- type CtxGetter
- type Opt
- type Settings
- func (s Settings) EnrichBy(in trm.Settings) trm.Settings
- func (s Settings) IsMulti() bool
- func (s Settings) IsMultiOrNil() *bool
- func (s Settings) Return() *[]redis.Cmder
- func (s Settings) SetIsMulti(in *bool) Settings
- func (s Settings) SetReturn(in *[]redis.Cmder) Settings
- func (s Settings) SetTxDecorators(in ...TxDecorator) Settings
- func (s Settings) SetWatchKeys(in []string) Settings
- func (s Settings) TxDecorators() []TxDecorator
- func (s Settings) WatchKeys() []string
- type Transaction
- type TxDecorator
- type Watch
Constants ¶
const ( // DefaultMulti is a default value for Settings.IsMulti. DefaultMulti = true )
Variables ¶
var DefaultCtxGetter = NewCtxGetter(trmcontext.DefaultManager)
DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey.
Functions ¶
func NewDefaultFactory ¶
NewDefaultFactory creates default trm.Transaction(redis.UniversalClient).
Types ¶
type Cmdable ¶
type Cmdable interface { redis.Cmdable Watch }
Cmdable is an experimental interface to Watch and Unwatch keys in Transaction.
func ReadOnlyFuncWithoutTxDecorator ¶
ReadOnlyFuncWithoutTxDecorator is decorator, which calls readonly commands outside of the Transaction.
type CtxGetter ¶
type CtxGetter struct {
// contains filtered or unexported fields
}
CtxGetter gets goredis8.Pipeliner from trm.СtxManager by casting trm.Transaction to redis.UniversalClient.
func NewCtxGetter ¶
func NewCtxGetter(c trm.СtxManager) *CtxGetter
NewCtxGetter returns *CtxGetter to get Cmdable from context.Context.
func (*CtxGetter) DefaultTrOrDB ¶
DefaultTrOrDB returns Cmdable from context.Context or DB(goredis8.Cmdable) otherwise.
type Opt ¶
Opt is a type to configure Settings.
func WithRet ¶
func WithRet(in *[]redis.Cmder) Opt
WithRet sets link on []redis.Cmder to get responses of commands in Transaction WARNING: Responses don't clean automatically, use WithRet only with DoWithSettings of trm.Manager.
func WithTxDecorator ¶
func WithTxDecorator(in TxDecorator) Opt
WithTxDecorator sets TxDecorator to change behavior of Transaction.
func WithWatchKeys ¶
WithWatchKeys sets WATCH keys in Transaction.
type Settings ¶
Settings contains settings for redis.Transaction.
func MustSettings ¶
MustSettings returns Settings if err is nil and panics otherwise.
func NewSettings ¶
NewSettings creates Settings.
func (Settings) IsMultiOrNil ¶
IsMultiOrNil returns IsMulti or nil.
func (Settings) Return ¶
func (s Settings) Return() *[]redis.Cmder
Return returns []redis.Cmder from Transaction.
func (Settings) SetIsMulti ¶
SetIsMulti set using or not Multi for transaction, see https://redis.uptrace.dev/guide/go-redis-pipelines.html#transactions.
func (Settings) SetTxDecorators ¶
func (s Settings) SetTxDecorators(in ...TxDecorator) Settings
SetTxDecorators sets TxDecorator decorators.
func (Settings) SetWatchKeys ¶
SetWatchKeys sets keys for watching, see https://redis.uptrace.dev/guide/go-redis-pipelines.html#watch.
func (Settings) TxDecorators ¶
func (s Settings) TxDecorators() []TxDecorator
TxDecorators returns TxDecorator decorators.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is trm.Transaction for sqlx.Tx.
func NewTransaction ¶
func NewTransaction( ctx context.Context, db redis.UniversalClient, s Settings, ) (context.Context, *Transaction, error)
NewTransaction creates trm.Transaction for sqlx.Tx.
func (*Transaction) Commit ¶
func (t *Transaction) Commit(_ context.Context) error
Commit closes 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(_ context.Context) error
Rollback the trm.Transaction.
func (*Transaction) Transaction ¶
func (t *Transaction) Transaction() interface{}
Transaction returns the real transaction sqlx.Tx. trm.NestedTrFactory returns IsActive as true while trm.Transaction is opened.
type TxDecorator ¶
TxDecorator is an interface for Transaction.tx decoration.