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)

End finish the hook invokation

type Hook

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

Hook represents a hook behaviour

type Hooks

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

Hooks implements Hook interface but contains multiple Hook

func (*Hooks) AddHook

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

AddHook adds a Hook

func (*Hooks) AfterProcess

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

AfterProcess invoked after exetue the process

func (*Hooks) BeforeProcess

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

BeforeProcess invoked before execute the process