defs

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: 9 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l *zap.Logger)

Types

type ConfigOption

type ConfigOption func(*ConfigOptions)

func ConfigCanLoadByConsul

func ConfigCanLoadByConsul(canLoadByConsul bool) ConfigOption

func ConfigFileName

func ConfigFileName(configFileName string) ConfigOption

func ConfigKey

func ConfigKey(configKey string) ConfigOption

type ConfigOptions

type ConfigOptions struct {
	// ConfigKey 配置标识
	ConfigKey string
	// CanLoadByConsul 是否从配置中心读取
	CanLoadByConsul bool
	// ConfigFileName 配置文件在根路径下的路径
	ConfigFileName string
}

func NewConfigOptions

func NewConfigOptions(opts ...ConfigOption) ConfigOptions

type ControllerOption

type ControllerOption func(*ControllerOptions)

func AuthCodes

func AuthCodes(authCodes ...string) ControllerOption

func HttpMethod

func HttpMethod(httpMethod string) ControllerOption

func Middlewares

func Middlewares(middlewares ...IHttpMiddleware) ControllerOption

func RelativePath

func RelativePath(relativePath string) ControllerOption

func SentinelStrategy

func SentinelStrategy(sentinelStrategy string) ControllerOption

type ControllerOptions

type ControllerOptions struct {
	// RelativePath 接口路径
	RelativePath string `validate:"required"`
	// HttpMethod 请求方法 使用 http.MethodGet 等相关枚举
	HttpMethod string `validate:"required"`
	// AuthCodes 接口资源编码,拥有任意一个资源就算通过
	AuthCodes []string `validate:"dive,required"`
	// Middlewares 自定义中间件
	Middlewares []IHttpMiddleware
	// SentinelStrategy 熔断限流策略,不同得接口不要使用相同得策略
	SentinelStrategy string
}

ControllerOptions 接口配置

func NewControllerOptions

func NewControllerOptions(opts ...ControllerOption) ControllerOptions

type IConfigDefine

type IConfigDefine interface {
	// GetOption 配置标识
	GetOption() ConfigOptions
	// ReloadConfig 配置变更通知,传入指针对象
	ReloadConfig(any) error
	// Unmarshal 反序列化对象,返回指针对象
	Unmarshal([]byte) (any, error)
}

IConfigDefine 动态配置定义

type IConsumer

type IConsumer interface {
	GetTopic() string
	HandleMessage(context.Context, []byte) error
}

type IController

type IController interface {
	// GetOption 关键配置
	GetOption() ControllerOptions
	// Handle 核心方法
	Handle(c *gin.Context)
}

type ID

type ID uint64

ID 主键

func (ID) Int

func (i ID) Int() int

func (ID) Int64

func (i ID) Int64() int64

func (ID) String

func (i ID) String() string

func (ID) UInt64

func (i ID) UInt64() uint64

func (ID) Uint

func (i ID) Uint() uint

type IGrpcMiddleware

type IGrpcMiddleware interface {
	MiddlewareWrapHandler() server.HandlerWrapper
}

type IGrpcServiceHandler

type IGrpcServiceHandler interface {
	// GrpcRegister 注册服务
	GrpcRegister(s server.Server) error
}

type IHttpMiddleware

type IHttpMiddleware interface {
	MiddlewareHandlerFunc(option *ControllerOptions) gin.HandlerFunc
}

type IRepo

type IRepo interface {
	AutoMigrate(ctx context.Context) error
}

type IScheduler

type IScheduler interface {
	// GetTaskTypeCode 定时任务编码,用于防止并发验证,要求全局唯一
	GetTaskTypeCode() string
	// GetSpec corn表达式
	GetSpec() string
	// GetLockDuration 并发限制间隔,多久时间内限制重复并发,0无锁
	GetLockDuration() time.Duration
	// RunTask 指定核心任务
	RunTask(contextx.Context) error
	// LoggerEnable 是否记录日志
	LoggerEnable() bool
}

type JwtClaims

type JwtClaims struct {
	jwt.RegisteredClaims
	// TenantID 租户ID
	TenantID string `json:"tenant_id,omitempty"`
	// UserID 用户ID
	UserID uint64 `json:"user_id,omitempty"`
	// Username 用户名
	Username string `json:"username,omitempty"`
	// Auths 资源许可
	Auths []string `json:"auths,omitempty"`
}

type LogLayout

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

LogLayout 日志layout

func NewLogLayout

func NewLogLayout(
	level zapcore.Level,
	svcMode uint8,
	svcName string,
	svcNum uint8,
	svcVersion string,
) *LogLayout

func (*LogLayout) AppendLogsFields

func (l *LogLayout) AppendLogsFields(logFields ...zap.Field)

func (*LogLayout) Error

func (l *LogLayout) Error(msg string, logFields ...zap.Field)

func (*LogLayout) Info

func (l *LogLayout) Info(msg string, logFields ...zap.Field)

func (LogLayout) Println

func (l LogLayout) Println()

Println 打印日志

func (*LogLayout) Warn

func (l *LogLayout) Warn(msg string, logFields ...zap.Field)

type ModelPO

type ModelPO struct {
	// 主键,默认自增长
	ID ID `gorm:"primarykey"`
	// 乐观锁
	Revision uint64 `gorm:"column:revision;comment:乐观锁"`
	// 创建时间戳
	CreatedAt uint64 `gorm:"<-:create;autoCreateTime:milli"`
	// 修改时间戳
	UpdatedAt uint64 `gorm:"autoUpdateTime:milli"`
	// 删除标识符
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (*ModelPO) BeforeCreate

func (m *ModelPO) BeforeCreate(tx *gorm.DB) (err error)

func (*ModelPO) BeforeUpdate

func (m *ModelPO) BeforeUpdate(tx *gorm.DB) (err error)

Jump to

Keyboard shortcuts

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