Documentation ¶
Index ¶
- Constants
- Variables
- func GetFuncName(f any) string
- func GetInterfaceType[T any](t *T) reflect.Type
- func NewSimpleLogger() (Goner, GonerId)
- func PanicTrace(kb int) []byte
- func Run(priests ...Priest)
- func Serve(priests ...Priest)
- func Test[T Goner](fn func(T), priests ...Priest)
- func TestAt[T Goner](id GonerId, fn func(T), priests ...Priest)
- type AfterReviveError
- type Angel
- type Cemetery
- type DefaultLoggerUser
- type Error
- func CannotFoundGonerByIdError(id GonerId) Error
- func CannotFoundGonerByTypeError(t reflect.Type) Error
- func GonerIdIsExistedError(id GonerId) Error
- func NewError(code int, msg string) Error
- func NewInnerError(code int, msg string) Error
- func NotCompatibleError(a reflect.Type, b reflect.Type) Error
- func ReplaceBuryIdParamEmptyError() Error
- type Flag
- type Goner
- type GonerId
- type Heaven
- type InnerError
- type Logger
- type Priest
- type Process
- type Prophet
- type SetLoggerError
- type SuckError
- type TestHeaven
- type Tomb
- type Tombs
- type Vampire
Constants ¶
View Source
const ( // GonerIdIsExisted GonerId 不存在 GonerIdIsExisted = 1001 + iota // CannotFoundGonerById 通过GonerId查找Goner失败 CannotFoundGonerById // CannotFoundGonerByType 通过类型查找Goner失败 CannotFoundGonerByType //NotCompatible 类型不兼容 NotCompatible //ReplaceBuryIdParamEmpty 替换性下葬,GonerId不能为空 ReplaceBuryIdParamEmpty )
错误代码:gone框架内部错误代码编码空间:1001~1999
View Source
const ( // IdGoneHeaven 天堂组件的ID,代码了程序本身,Gone程序启动时默认注入 IdGoneHeaven = "gone-heaven" // IdGoneCemetery 坟墓组件的ID,是完成依赖注入的关键组件,Gone程序启动时默认注入 IdGoneCemetery = "gone-cemetery" //IdGoneTestKit 测试箱,调用 gone.Test 或者 gone.TestAt 时,会将测试箱注入到程序;非测试代码中不应该注入该组件 IdGoneTestKit = "gone-test-kit" //IdConfig 配置 Goner 的ID,提过能配置能力 IdConfig = "config" //IdGoneConfigure 配置器 Goner 的ID IdGoneConfigure = "gone-configure" // IdGoneTracer Tracer Goner 的ID,提供日志追踪能力 IdGoneTracer = "gone-tracer" // IdGoneLogger 日志 Goner 的ID,用于日志打印 IdGoneLogger = "gone-logger" //IdGoneCumx [cmux Goner](/goner/cmux#Server) ID IdGoneCumx = "gone-cumx" //IdGoneGin Gin相关的组件ID,可以使用 [goner.GinPriest](goner#GinPriest) 牧师函数批量安葬 IdGoneGin = "gone-gin" IdGoneGinRouter = "gone-gin-router" IdGoneGinProcessor = "gone-gin-processor" IdGoneGinProxy = "gone-gin-proxy" IdGoneGinResponser = "gone-gin-responser" //IdGoneXorm Xorm Goner 的ID,封装了xorm,用于操作数据库;使用 [goner.XormPriest](goner#XormPriest) 牧师函数安葬 IdGoneXorm = "gone-xorm" //IdGoneRedisPool redis pool goner; redis 相关 Goner,使用 [goner.RedisPriest](goner#RedisPriest) 牧师函数安葬 IdGoneRedisPool = "gone-redis-pool" IdGoneRedisCache = "gone-redis-cache" IdGoneRedisKey = "gone-redis-key" IdGoneRedisLocker = "gone-redis-locker" IdGoneRedisProvider = "gone-redis-provider" // IdGoneSchedule 定时器Goner;使用 [goner.SchedulePriest](goner#SchedulePriest) 牧师函数安葬 IdGoneSchedule = "gone-schedule" IdGoneReq = "gone-urllib" )
Gone框架中的内置组件ID
Variables ¶
View Source
var AfterStopSignalWaitSecond = 10
AfterStopSignalWaitSecond 收到停机信号后,退出程序等待的时间
Functions ¶
func GetInterfaceType ¶ added in v0.0.17
GetInterfaceType 获取接口的类型
func NewSimpleLogger ¶ added in v0.0.8
func Run ¶
func Run(priests ...Priest)
Run 开始运行一个Gone程序;`gone.Run` 和 `gone.Serve` 的区别是: 1. gone.Serve启动的程序,主协程会调用 Heaven.WaitEnd 挂起等待停机信号,可以用于服务程序的开发 2. gone.Run启动的程序,主协程则不会挂起,运行完就结束,适合开发一致性运行的代码
// 定义加载服务的Priest函数 func LoadServer(c Cemetery) error { c.Bury(goneXorm.New()) c.Bury(goneGin.New()) return nil } // 加载组件的Priest函数 func LoadComponent(c Cemetery) error { c.Bury(componentA.New()) c.Bury(componentB.New()) } gone.Run(LoadServer, LoadComponent)//开始运行
func Test ¶ added in v0.0.6
Test 用于编写测试用例,参考[示例](https://github.com/gone-io/gone/blob/main/example/test/goner_test.go)
Types ¶
type AfterReviveError ¶ added in v0.0.6
type AfterReviveError error
type Cemetery ¶
type Cemetery interface { DefaultLoggerUser Goner Bury(Goner, ...GonerId) Cemetery // 埋葬,将逝者埋葬到墓园 ReplaceBury(Goner, GonerId) error // 替换性埋葬 GetTomById(GonerId) Tomb GetTomByType(reflect.Type) []Tomb // contains filtered or unexported methods }
Cemetery 墓园
type DefaultLoggerUser ¶ added in v0.0.17
type DefaultLoggerUser interface {
SetLogger(logger Logger) SetLoggerError
}
type Error ¶
Error 普通错误
func GonerIdIsExistedError ¶
func NewInnerError ¶ added in v0.0.6
func ReplaceBuryIdParamEmptyError ¶
func ReplaceBuryIdParamEmptyError() Error
type Heaven ¶
type InnerError ¶ added in v0.0.6
InnerError 内部错误
type Prophet ¶ added in v0.0.6
type Prophet interface { Goner //AfterRevive 在Goner复活后会被执行 AfterRevive() AfterReviveError }
Prophet 先知
type SetLoggerError ¶ added in v0.0.17
type SetLoggerError error
type TestHeaven ¶
type TestHeaven[T Goner] interface { Heaven WithId(id GonerId) TestHeaven[T] WithPriest(priests ...Priest) TestHeaven[T] Run() }
func TestKit ¶
func TestKit[T Goner](fn func(T)) TestHeaven[T]
type Tomb ¶
type Tomb interface { SetId(GonerId) Tomb GetId() GonerId GetGoner() Goner GonerIsRevive(flags ...bool) bool }
Tomb 坟墓,逝者的容器
Source Files ¶
Click to show internal directories.
Click to hide internal directories.