context

package
v2.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 4 Imported by: 7

Documentation

Overview

Package context implement a setter and getter to put and get trm.Transaction from context.Context.

Index

Constants

This section is empty.

Variables

View Source
var DefaultManager = New(settings.DefaultCtxKey) //nolint:gochecknoglobals

DefaultManager is a trm.СtxManager with settings.DefaultCtxKey.

Functions

func Generate

func Generate() trm.CtxKey

Generate unique trm.CtxKey by KeyGenerator.

Types

type KeyGenerator

type KeyGenerator struct {
	// contains filtered or unexported fields
}

KeyGenerator is a generator of trm.CtxKey.

func NewKeyGenerator

func NewKeyGenerator() *KeyGenerator

NewKeyGenerator creates KeyGenerator.

func (*KeyGenerator) Generate

func (g *KeyGenerator) Generate() trm.CtxKey

Generate unique trm.CtxKey.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager implements trm.СtxManager.

func New

func New(ctxKey trm.CtxKey) *Manager

New is a factory for Manager.

func (*Manager) ByKey

func (c *Manager) ByKey(ctx context.Context, key trm.CtxKey) trm.Transaction

ByKey returns trm.Transaction from context.Context by key(trm.CtxKey).

func (*Manager) Default

func (c *Manager) Default(ctx context.Context) trm.Transaction

Default returns trm.Transaction from context.Context by default key.

func (*Manager) SetByKey

func (c *Manager) SetByKey(ctx context.Context, key trm.CtxKey, t trm.Transaction) context.Context

SetByKey puts trm.Transaction in context.Context by key(trm.CtxKey).

func (*Manager) SetDefault

func (c *Manager) SetDefault(ctx context.Context, t trm.Transaction) context.Context

SetDefault puts trm.Transaction in context.Context by default key.

Jump to

Keyboard shortcuts

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