Documentation
¶
Index ¶
- Constants
- Variables
- func AppendToFile[T any](c chan T, fileName string)
- func BeforeBootup(key string)
- func Clone(original any, target any) error
- func CloseOnlyNotified()
- func CreateFs(path string) (afero.Fs, error)
- func Decrypt(key, src []byte) ([]byte, error)
- func Encrypt(key, raw []byte) ([]byte, error)
- func EncryptConfig() error
- func EnsureDir(fs afero.Fs, dir string) error
- func GetContainer() *dig.Container
- func GetService[T any]() T
- func GetStructNameOnly[T any](rr T) string
- func InitConfig(p Bootup) error
- func InitEmbedConfig()
- func InitLogger(p Bootup) (*zap.Logger, error)
- func InvokeAsyncOnServiceStarted(fn any)
- func InvokeOnServiceStarted(fn any)
- func IsStructOrPtrToStruct(v interface{}) bool
- func MD5(raw []byte) string
- func NotifyStarted()
- func NotifyStopping()
- func OnEvent(topic string, fn any)
- func OnServiceStarted(fn SystenEvent)
- func OnServiceStopping(fn SystenEvent)
- func PrintVersion()
- func Provide(constructor ...interface{})
- func ProvideStartup(constructor ...any)
- func ReadEncryptConfig(secret []byte, toFile string) error
- func ReadYamlfile(configname string) (*viper.Viper, error)
- func ReplaceTablePrefix(raw string, prefixes ...string) string
- func ToAnyChan[T any](input chan T) chan any
- func ToEmbedConfig(content []byte, keys ...string)
- func ToMd5(items ...any) string
- type BlockingQueue
- type Bootup
- type ChanAdaptor
- type ConfigSecret
- type EmbedConfigReady
- type ErrorReport
- type Handler
- type Md5Value
- type OptionalParam
- type RootRootCtx
- type ServiceParam
- type Startup
- type Startups
- type SystenEvent
Constants ¶
View Source
const ( // EventError = "event.error" EventTracing = "event.tracing" EventInit = "event.gin.inited" //trigger when gin ready to service. EventStopping = "event.gin.stopping" EventStarted = "sys.started" //trigger when all inited done. )
View Source
const (
EncryptedFile = "config/app.cfg"
)
Variables ¶
View Source
var AppName = "RFID_App"
View Source
var Bus = EventBus.New()
View Source
var ConfigFolder = "config"
View Source
var Container = dig.New()
View Source
var DefaultFolder = "./data"
View Source
var ErrQueueClosed = errors.New("queue has been closed")
View Source
var ErrorAdaptor = NewChanAdaptor[ErrorReport](1000) // error adaptor for monitor error.
View Source
var (
GraceShutdown = 5 * time.Second
)
View Source
var StartupOptions = dig.Group("startups")
View Source
var Version = "latest"
Functions ¶
func AppendToFile ¶ added in v0.10.10
func BeforeBootup ¶ added in v0.8.20
func BeforeBootup(key string)
func CloseOnlyNotified ¶ added in v0.8.15
func CloseOnlyNotified()
func EncryptConfig ¶ added in v0.8.14
func EncryptConfig() error
func GetContainer ¶
func GetService ¶ added in v0.10.7
func GetService[T any]() T
func GetStructNameOnly ¶ added in v0.10.19
func InitConfig ¶
func InitEmbedConfig ¶ added in v0.8.17
func InitEmbedConfig()
make sure run it in main before init anything, just make sure, all embed config inited.
func InvokeAsyncOnServiceStarted ¶ added in v0.8.15
func InvokeAsyncOnServiceStarted(fn any)
func InvokeOnServiceStarted ¶ added in v0.8.15
func InvokeOnServiceStarted(fn any)
func IsStructOrPtrToStruct ¶ added in v0.11.5
func IsStructOrPtrToStruct(v interface{}) bool
func NotifyStarted ¶ added in v0.7.8
func NotifyStarted()
func NotifyStopping ¶ added in v0.8.11
func NotifyStopping()
func OnServiceStarted ¶ added in v0.8.11
func OnServiceStarted(fn SystenEvent)
OnServiceStarted make sure call this func after
func OnServiceStopping ¶ added in v0.8.11
func OnServiceStopping(fn SystenEvent)
func PrintVersion ¶ added in v0.8.15
func PrintVersion()
func ProvideStartup ¶ added in v0.5.1
func ProvideStartup(constructor ...any)
func ReadEncryptConfig ¶ added in v0.8.14
func ReplaceTablePrefix ¶ added in v0.11.2
func ToEmbedConfig ¶ added in v0.5.4
Types ¶
type BlockingQueue ¶ added in v0.11.5
type BlockingQueue[T any] struct { // contains filtered or unexported fields }
func NewBlockingQueue ¶ added in v0.11.5
func NewBlockingQueue[T any]() *BlockingQueue[T]
func (*BlockingQueue[T]) Clear ¶ added in v0.11.5
func (q *BlockingQueue[T]) Clear()
Clear 清空当前所有缓存的数据
func (*BlockingQueue[T]) Close ¶ added in v0.11.5
func (q *BlockingQueue[T]) Close()
Close 关闭队列,唤醒所有等待的 Pop,使其返回 (zero, false)
func (*BlockingQueue[T]) Pop ¶ added in v0.11.5
func (q *BlockingQueue[T]) Pop() (T, bool)
Pop 从队列取出元素,如果为空则阻塞,直到有数据或队列被清空/关闭 返回值: value, ok
ok == true: 正常取出数据 ok == false: 队列已关闭或被清空后无新数据
func (*BlockingQueue[T]) Push ¶ added in v0.11.5
func (q *BlockingQueue[T]) Push(v T) error
Push 向队列推入元素,不会阻塞(除非你加长度限制)
type Bootup ¶ added in v0.5.4
type Bootup struct {
dig.In
Secret ConfigSecret
EmbedConfigReady EmbedConfigReady
}
type ChanAdaptor ¶ added in v0.10.9
Even Bus is good, but can't controll conconcurreny well and performance is not as good as chan, target to replace all eventbus with chanAdaptor.
func NewChanAdaptor ¶ added in v0.10.9
func NewChanAdaptor[T any](buf int) *ChanAdaptor[T]
func (*ChanAdaptor[T]) Push ¶ added in v0.10.9
func (ca *ChanAdaptor[T]) Push(data T)
func (*ChanAdaptor[T]) Receivers ¶ added in v0.11.0
func (ca *ChanAdaptor[T]) Receivers() []string
func (*ChanAdaptor[T]) Start ¶ added in v0.10.9
func (ca *ChanAdaptor[T]) Start()
make sure all receivers reg before start()
func (*ChanAdaptor[T]) Stop ¶ added in v0.11.5
func (ca *ChanAdaptor[T]) Stop()
func (*ChanAdaptor[T]) Sub ¶ added in v0.10.10
func (ca *ChanAdaptor[T]) Sub(receiver string) chan T
func (*ChanAdaptor[T]) Subscripter ¶ added in v0.10.9
func (ca *ChanAdaptor[T]) Subscripter(receiver string, fn Handler[T])
type ConfigSecret ¶ added in v0.8.14
type ConfigSecret []byte
type EmbedConfigReady ¶ added in v0.8.17
type EmbedConfigReady interface{}
type ErrorReport ¶ added in v0.10.13
type OptionalParam ¶ added in v0.5.7
type RootRootCtx ¶ added in v0.10.15
func RootCtx ¶ added in v0.10.15
func RootCtx() RootRootCtx
type ServiceParam ¶ added in v0.8.3
type SystenEvent ¶ added in v0.8.11
type SystenEvent func()
Click to show internal directories.
Click to hide internal directories.