contexts

package
v0.0.0-...-386c639 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryContextCache

func NewMemoryContextCache() memoryContextCache

NewMemoryContextCache return memoryContextCache

Types

type ContextCache

type ContextCache interface {
	// Put puts value into cache with key.
	Put(key string, val interface{})
	// Get gets cached value by given key.
	Get(key string) interface{}
}

ContextCache is the interface that operates the cache data.

type ContextHook

type ContextHook struct {
	Ctx         context.Context
	SQL         string        // log content or SQL
	Args        []interface{} // if it's a SQL, it's the arguments
	Result      sql.Result
	ExecuteTime time.Duration
	Err         error // SQL executed error
	// contains filtered or unexported fields
}

ContextHook represents a hook context

func NewContextHook

func NewContextHook(ctx context.Context, sql string, args []interface{}) *ContextHook

NewContextHook return context for hook

func (*ContextHook) End

func (c *ContextHook) End(ctx context.Context, result sql.Result, err error)

type Hook

type Hook interface {
	BeforeProcess(c *ContextHook) (context.Context, error)
	AfterProcess(c *ContextHook) error
}

type Hooks

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

func (*Hooks) AddHook

func (h *Hooks) AddHook(hooks ...Hook)

func (*Hooks) AfterProcess

func (h *Hooks) AfterProcess(c *ContextHook) error

func (*Hooks) BeforeProcess

func (h *Hooks) BeforeProcess(c *ContextHook) (context.Context, error)

Jump to

Keyboard shortcuts

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