context

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTx

func WithTx(ctx Context, f func(ctx Context) error) (err error)

Types

type Context

type Context interface {
	context.Context

	// 获取DB实例
	DB() db.DB
	// 获取日志实例
	Logger() utillog.Logger
	// 获取当前登录用户ID
	UserID() int
	// 获取请求ID
	RequestID() string

	// 取消
	Cancel()

	// 设置Context
	SetContext(context.Context)

	// 设置用户ID
	SetUserID(userID int)

	// 设置请求ID
	SetRequestID(string)

	// 返回一个新的Context,并设置tx
	NewWithTx(db.DB) Context
}

Context 上下文

func New

func New(db db.DB, logger utillog.Logger, userID int) Context

New 新建

Jump to

Keyboard shortcuts

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