uctx

package
v0.0.0-...-9fd2f02 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppTransaction

func AppTransaction(ctx context.Context, fn func(context.Context) error) error

func AppendLogsFields

func AppendLogsFields(ctx context.Context, fields ...zap.Field)

func CreateJwtClaimsToken

func CreateJwtClaimsToken(claims defs.JwtClaims) (string, error)

func Error

func Error(ctx context.Context, msg string, fields ...zap.Field)

func GetAppDB

func GetAppDB(ctx context.Context) *gorm.DB

func GetAppDBWithCtx

func GetAppDBWithCtx(ctx context.Context) *gorm.DB

func GetJwtClaims

func GetJwtClaims(ctx context.Context) (defs.JwtClaims, error)

func GetJwtClaimsByBearerToken

func GetJwtClaimsByBearerToken(c *gin.Context) (defs.JwtClaims, error)

func GetJwtClaimsByGrpcCtx

func GetJwtClaimsByGrpcCtx(ctx context.Context) (context.Context, defs.JwtClaims, error)

func GetLogLayout

func GetLogLayout(ctx context.Context) *defs.LogLayout

func GetSpanContext

func GetSpanContext(ctx context.Context) context.Context

func GetTenantID

func GetTenantID(ctx context.Context) string

func GetTenantIDByGrpcCtx

func GetTenantIDByGrpcCtx(ctx context.Context) (context.Context, string)

func GetTenantTableDBWithCtx

func GetTenantTableDBWithCtx(ctx context.Context, tablePrefile string) *gorm.DB

func GetTraceID

func GetTraceID(ctx context.Context) string

func GetTraceIDByGrpcCtx

func GetTraceIDByGrpcCtx(ctx context.Context) (context.Context, string)

func GetTraceSpanIDByGrpcCtx

func GetTraceSpanIDByGrpcCtx(ctx context.Context) string

func NewJwtClaimsToken

func NewJwtClaimsToken(
	tenantID string,
	userID uint64,
	username string,
	auths []string,
	accessTokenExpTime int64,
) (string, error)

func ParseYhUserTokenClaims

func ParseYhUserTokenClaims(tokenString string) (*defs.JwtClaims, error)

func SetLogLayout2GinCtx

func SetLogLayout2GinCtx(ctx *gin.Context, layout *defs.LogLayout)

func SetSpanContext

func SetSpanContext(ctx *gin.Context, spanCtx context.Context)

func SetTraceID

func SetTraceID(ctx *gin.Context, traceID string)

func ShouldBindJSON

func ShouldBindJSON[T any](c *gin.Context, obj T, check func(arg T) bool, rs ...any) (ctx context.Context, err error)

ShouldBindJSON 解析并验证请求body参数,返回链路span上下文 check:额外自定义的VO校验方法

func ShouldBindQuery

func ShouldBindQuery[T any](c *gin.Context, obj T, check func(arg T) bool, rs ...any) (ctx context.Context, err error)

ShouldBindQuery 解析并验证请求query参数,返回链路span上下文 check:额外自定义的VO校验方法

func Warn

func Warn(ctx context.Context, msg string, fields ...zap.Field)

func WithValueAppDB

func WithValueAppDB(ctx context.Context, db *gorm.DB) context.Context

func WithValueLogLayout

func WithValueLogLayout(ctx context.Context, layout *defs.LogLayout) context.Context

func WithValueTenant

func WithValueTenant(ctx context.Context, tenantID string) context.Context

func WithValueTenantID

func WithValueTenantID(ctx context.Context, tenantID string) context.Context

func WithValueTraceID

func WithValueTraceID(ctx context.Context, traceID string) context.Context

Types

This section is empty.

Jump to

Keyboard shortcuts

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