framework

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

README

说明

common

starter
  • Start 方法,启动
    • 启动顺序
      • 系统 初始化
      • 触发 EventSystemInitBefore 事件
      • init config 初始化 配置 开始
        • 触发 EventConfigInitBefore 事件
        • 执行 config init func,按照 Order 正序执行
        • 触发 EventConfigInitAfter 事件
      • init component 初始化 组件 开始
        • 触发 EventComponentInitBefore 事件
        • 执行 component init func,按照 Order 正序执行
        • 触发 EventComponentInitAfter 事件
      • init factory 初始化 组件 开始
        • 触发 EventFactoryInitBefore 事件
        • 执行 factory init func,按照 Order 正序执行
        • 触发 EventFactoryInitAfter 事件
      • init table 初始化 表 开始
        • 触发 EventTableInitBefore 事件
        • 执行 table init func,按照 Order 正序执行
        • 触发 EventTableInitAfter 事件
      • init data 初始化 数据 开始
        • 触发 EventDataInitBefore 事件
        • 执行 data init func,按照 Order 正序执行
        • 触发 EventDataInitAfter 事件
      • 触发 EventSystemInitAfter 事件
      • 系统 启动服务
      • 触发 EventServerStartBefore 事件
        • 执行 server start func,按照 Order 正序执行
      • 触发 EventServerStartAfter 事件
      • 触发 EventReady 事件
  • AddInitConfigFunc 添加 初始化 配置 函数
  • AddInitComponentFunc 添加 初始化 组件 函数
  • AddInitFactoryFunc 添加 初始化 工厂 函数
  • AddInitTableFunc 添加 初始化 表 函数
  • AddInitDataFunc 添加 初始化 数据 函数
  • AddServerStartFunc 添加 服务 启动 函数
  • OnEvent 添加 事件 监听
  • CallEvent 触发 事件
  • SetShouldWait 设置 是否需要 Wait 通常 系统包含服务时候需要设置 true
  • Wait 阻塞线程 防止退出
error
  • 自定义异常,自定义属性
  • code: 错误码
  • msg: 错误信息
logger
  • 日志

db

dialect 数据库方言
  • 数据库 DDL 语句
  • 数据库 分页 语句
  • 数据库 SQL 参数占位符
  • 数据库 数据类型
  • 数据库 常用函数
service 数据库服务
  • 表数据 增、删、改、查
  • 结构体 > 增、改 SQL
sql 动态 SQL
  • 表数据 增、删、改、查
  • 结构体 > 增、改 SQL

Documentation

Index

Constants

View Source
const (
	EventSystemInitBefore = Event("system-init-before-event")

	EventSystemInitAfter = Event("system-init-after-event")

	EventConfigInitBefore = Event("config-init-before-event")

	EventConfigInitAfter = Event("config-init-after-event")

	EventComponentInitBefore = Event("component-init-before-event")

	EventComponentInitAfter = Event("component-init-after-event")

	EventFactoryInitBefore = Event("factory-init-before-event")

	EventFactoryInitAfter = Event("factory-init-after-event")

	EventTableInitBefore = Event("table-init-before-event")

	EventTableInitAfter = Event("table-init-after-event")

	EventDataInitBefore = Event("data-init-before-event")

	EventDataInitAfter = Event("data-init-after-event")

	EventServerStartBefore = Event("server-start-before-event")

	EventServerStartAfter = Event("server-start-after-event")

	EventReady = Event("ready-event")

	EventStopBefore = Event("stop-before-event")

	EventStop = Event("stop-event")
)

Variables

This section is empty.

Functions

func Debug

func Debug(str string, args ...any)

func Debug2

func Debug2(str string, args ...any)

func Error

func Error(str string, args ...any)

func Error2

func Error2(str string, args ...any)

func Fatal

func Fatal(str string, args ...any)

func Fatal2

func Fatal2(str string, args ...any)

func FormatConfigMap

func FormatConfigMap(mapValue map[string]any, mapType reflect.Type)

func FormatZapArgs

func FormatZapArgs(args ...interface{}) (res []any, fields []zap.Field)

func GetDefaultOptions

func GetDefaultOptions(skip int) (options []zap.Option)

func GetFromSystem

func GetFromSystem(key string) string

func GetGitCommit

func GetGitCommit() string

func GetPwdDir

func GetPwdDir() string

func GetReleaseTime

func GetReleaseTime() string

func GetReleaseVersion

func GetReleaseVersion() string

func Info

func Info(str string, args ...any)

func Info2

func Info2(str string, args ...any)

func IsVersion

func IsVersion() bool

func LoggerInit

func LoggerInit(c *LogConfig)

func NewEncoderConfig

func NewEncoderConfig() zapcore.EncoderConfig

func NewLoggerByCallerSkip

func NewLoggerByCallerSkip(l *zap.Logger, skip int) *zap.Logger

NewLoggerByCallerSkip 跳过的调用方数量 skip = 1 表示 输出的 文件名 行号等 为上层方法

func NewZapLogger

func NewZapLogger(c *LogConfig) *zap.Logger

NewZapLogger creator a new zap logger hook {Filename, Maxsize(megabytes), MaxBackups, MaxAge(days)} level zap.Level { DebugLevel, InfoLevel, WarnLevel, ErrorLevel, }

func OnSignal

func OnSignal(fn func())

func OutInfo

func OutInfo()

func ReadConfig

func ReadConfig[C any](conf string) (cfg C, err error)

func Warn

func Warn(str string, args ...any)

func Warn2

func Warn2(str string, args ...any)

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

Cache 临时缓存结构

func NewCache

func NewCache[T any](obj T) *Cache[T]

NewCache 创建 默认 缓存

func NewCacheByOptions

func NewCacheByOptions[T any](opts *CacheOptions, obj T) *Cache[T]

NewCacheByOptions 创建一个 带策略的 缓存

func (*Cache[T]) Clear

func (this_ *Cache[T]) Clear()

Clear 清理

func (*Cache[T]) Delete

func (this_ *Cache[T]) Delete(keys ...string)

Delete 删除

func (*Cache[T]) Get

func (this_ *Cache[T]) Get(key string) (res T, find bool)

Get 从缓存中获取一个项

func (*Cache[T]) GetAnRemove

func (this_ *Cache[T]) GetAnRemove(key string) (res T, find bool)

GetAnRemove 从缓存中获取一个项

func (*Cache[T]) GetOrLoad

func (this_ *Cache[T]) GetOrLoad(key string, load func() (T, error)) (res T, err error)

GetOrLoad 从缓存中获取一个项 如果没有 则调用 load 加载

func (*Cache[T]) Put

func (this_ *Cache[T]) Put(key string, v T)

func (*Cache[T]) PutIfAbsent

func (this_ *Cache[T]) PutIfAbsent(key string, v T)

PutIfAbsent 不存在则新增

func (*Cache[T]) Remove

func (this_ *Cache[T]) Remove(removeKeys ...string)

Remove 清理 缓存

func (*Cache[T]) Set

func (this_ *Cache[T]) Set(key string, value T)

Set 从缓存中获取一个项 如果没有 则调用 load 加载

type CacheGroup

type CacheGroup[T any] struct {
	// contains filtered or unexported fields
}

func NewCacheGroup

func NewCacheGroup[T any](cacheSize int, obj T) *CacheGroup[T]

func NewCacheGroupByOption

func NewCacheGroupByOption[T any](cacheSize int, opts *CacheOptions, obj T) *CacheGroup[T]

func (*CacheGroup[T]) Clear

func (this_ *CacheGroup[T]) Clear()

Clear 清理

func (*CacheGroup[T]) Delete

func (this_ *CacheGroup[T]) Delete(keys ...string)

Delete 删除

func (*CacheGroup[T]) Get

func (this_ *CacheGroup[T]) Get(key string) (T, bool)

func (*CacheGroup[T]) GetCache

func (this_ *CacheGroup[T]) GetCache(key string) *Cache[T]

func (*CacheGroup[T]) GetCacheByHash

func (this_ *CacheGroup[T]) GetCacheByHash(hashCode uint32) *Cache[T]

func (*CacheGroup[T]) GetStringHashCode

func (this_ *CacheGroup[T]) GetStringHashCode(str string) uint32

func (*CacheGroup[T]) Put

func (this_ *CacheGroup[T]) Put(key string, v T)

Put 设置值

func (*CacheGroup[T]) PutIfAbsent

func (this_ *CacheGroup[T]) PutIfAbsent(key string, v T)

PutIfAbsent 不存在则新增

type CacheItem

type CacheItem[T any] struct {
	// contains filtered or unexported fields
}

CacheItem 缓存项结构

type CacheOptions

type CacheOptions struct {
	Limit  int   // 缓存大小限制
	Ttl    int64 // 缓存项存活时间 毫秒
	OutLog bool
}

type CoreError

type CoreError struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
}

func NewError

func NewError(code string, msg string) *CoreError

NewError 构造异常对象,code为错误码,msg为错误信息

func (*CoreError) Error

func (this_ *CoreError) Error() string

func (*CoreError) GetCode

func (this_ *CoreError) GetCode() string

func (*CoreError) GetMsg

func (this_ *CoreError) GetMsg() string

type DoFunc

type DoFunc struct {
	Name  string `json:"name"`
	Order int    `json:"order"`
	// contains filtered or unexported fields
}

type DoFuncList

type DoFuncList []*DoFunc

func (DoFuncList) Len

func (a DoFuncList) Len() int

func (DoFuncList) Less

func (a DoFuncList) Less(i, j int) bool

Less 根据 版本号数字 和 顺序号 排序 数值越大 越靠后

func (DoFuncList) Sort

func (a DoFuncList) Sort()

func (DoFuncList) Swap

func (a DoFuncList) Swap(i, j int)

type Event

type Event string

type EventContext

type EventContext interface {
	GetEvent() Event
	GetContext() context.Context
}

type Listener

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

type ListenerList

type ListenerList []*Listener

func (ListenerList) Len

func (p ListenerList) Len() int

func (ListenerList) Less

func (p ListenerList) Less(i, j int) bool

func (ListenerList) Sort

func (p ListenerList) Sort()

func (ListenerList) Swap

func (p ListenerList) Swap(i, j int)

type LogConfig

type LogConfig struct {
	Console    bool   `json:"console,omitempty" yaml:"console,omitempty"`
	Filename   string `json:"filename,omitempty" yaml:"filename,omitempty"`
	MaxSize    int    `json:"maxSize,omitempty" yaml:"maxSize,omitempty"`
	MaxAge     int    `json:"maxAge,omitempty" yaml:"maxAge,omitempty"`
	MaxBackups int    `json:"maxBackups,omitempty" yaml:"maxBackups,omitempty"`
	Level      string `json:"level,omitempty" yaml:"level,omitempty"`
}

type Logger

type Logger interface {
	Debug(str string, args ...any)
	Info(str string, args ...any)
	Warn(str string, args ...any)
	Error(str string, args ...any)
	Fatal(str string, args ...any)
}
var (
	DefaultLogger Logger
	Skip1Logger   Logger
	Skip2Logger   Logger
)

type Starter

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

func NewStarter

func NewStarter() (res *Starter)

func (*Starter) AddInitComponentFunc

func (this_ *Starter) AddInitComponentFunc(name string, order int, fn func() error)

func (*Starter) AddInitConfigFunc

func (this_ *Starter) AddInitConfigFunc(name string, order int, fn func() error)

func (*Starter) AddInitDataFunc

func (this_ *Starter) AddInitDataFunc(name string, order int, fn func() error)

func (*Starter) AddInitFactoryFunc

func (this_ *Starter) AddInitFactoryFunc(name string, order int, fn func() error)

func (*Starter) AddInitTableFunc

func (this_ *Starter) AddInitTableFunc(name string, order int, fn func() error)

func (*Starter) AddServerStartFunc

func (this_ *Starter) AddServerStartFunc(name string, order int, fn func() error)

func (*Starter) CallEvent

func (this_ *Starter) CallEvent(event Event, args ...any)

func (*Starter) CallStop

func (this_ *Starter) CallStop()

func (*Starter) DoInit

func (this_ *Starter) DoInit() (err error)

func (*Starter) GetListeners

func (this_ *Starter) GetListeners(event Event) (res []*Listener)

func (*Starter) OnEvent

func (this_ *Starter) OnEvent(event Event, onEvent func(args ...any), order int)

func (*Starter) ServerStart

func (this_ *Starter) ServerStart() (err error)

func (*Starter) SetShouldWait

func (this_ *Starter) SetShouldWait(v bool)

func (*Starter) ShouldWait

func (this_ *Starter) ShouldWait() bool

func (*Starter) Start

func (this_ *Starter) Start() (err error)

func (*Starter) Wait

func (this_ *Starter) Wait()

type TError

type TError interface {
	error
	GetCode() string
	GetMsg() string
}

Directories

Path Synopsis
dialects
dm
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* Copyright (c) 2000-2018, 达梦数据库有限公司.
dm/parser
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* Copyright (c) 2000-2018, 达梦数据库有限公司.
dm/security
This is a mirror of golang.org/x/crypto/internal/subtle.
This is a mirror of golang.org/x/crypto/internal/subtle.
dm/util
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* Copyright (c) 2000-2018, 达梦数据库有限公司.
kingbase_v8r3/gokb
Package kb is a pure Go Kingbase driver for the database/sql package.
Package kb is a pure Go Kingbase driver for the database/sql package.
kingbase_v8r3/gokb/oid
Package oid contains OID constants as defined by the Kingbase server.
Package oid contains OID constants as defined by the Kingbase server.
kingbase_v8r3/gokb/scram
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
kingbase_v8r6/gokb
Package kb is a pure Go Kingbase driver for the database/sql package.
Package kb is a pure Go Kingbase driver for the database/sql package.
kingbase_v8r6/gokb/oid
Package oid contains OID constants as defined by the Kingbase server.
Package oid contains OID constants as defined by the Kingbase server.
kingbase_v8r6/gokb/scram
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
odbc
Package odbc implements database/sql driver to access data via odbc interface.
Package odbc implements database/sql driver to access data via odbc interface.
web

Jump to

Keyboard shortcuts

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