biz

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrCodeInternal // internal error
)

define utils error code

View Source
const (
	ErrCodeModuleRoot = ErrCodeStart * (1 + iota)
)

ErrCodeModuleRoot define error code module, e,g: 10000, 20000, 30000...

View Source
const ErrCodeStart = 10000

ErrCodeStart 业务逻辑错误代码开始值

Variables

This section is empty.

Functions

func NewOutgoingGrpcContext

func NewOutgoingGrpcContext(ctx Context) context.Context

NewOutgoingGrpcContext biz.Context => GRPC context

func ToGrpcError

func ToGrpcError(err error) error

Types

type Context

type Context interface {
	MetaData() meta.MetaData // 元数据
	Transactor() transactor  // 数据库Transactor相关
	Tid() int64              // 获取租户ID
	Uid() int64              // 获取用户ID
	AppKey() string          // 获取应用ID
	Source() string          // 获取请求来源
	RoleIds() []int64        // 获取角色ID列表
}

func NewContext

func NewContext(kvs ...string) Context

func NewFromIncomingGrpcContext

func NewFromIncomingGrpcContext(ctx context.Context) Context

NewFromIncomingGrpcContext GRPC context => biz.Context

type Error

type Error interface {
	error
	Code() int
}

func FromGrpcError

func FromGrpcError(err error) Error

FromGrpcError 从grpc status error获取额外的错误信息

func InternalError

func InternalError(message string) Error

func NewError

func NewError[T constraints.Integer](code T, message string) Error

NewError new error with error code

Jump to

Keyboard shortcuts

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