core

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 25 Imported by: 10

Documentation

Index

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 StartupOptions = dig.Group("startups")
View Source
var Version = "latest"

Functions

func BeforeBootup added in v0.8.20

func BeforeBootup(key string)

func Clone added in v0.10.4

func Clone(original any, target any) error

func CloseOnlyNotified added in v0.8.15

func CloseOnlyNotified()

func Decrypt added in v0.8.14

func Decrypt(key, src []byte) ([]byte, error)

func Encrypt added in v0.8.14

func Encrypt(key, raw []byte) ([]byte, error)

func EncryptConfig added in v0.8.14

func EncryptConfig() error

func GetContainer

func GetContainer() *dig.Container

func GetService added in v0.10.7

func GetService[T any]() T

func InitConfig

func InitConfig(p Bootup) error

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 InitLogger

func InitLogger(p Bootup) (*zap.Logger, error)

func InvokeAsyncOnServiceStarted added in v0.8.15

func InvokeAsyncOnServiceStarted(fn any)

func InvokeOnServiceStarted added in v0.8.15

func InvokeOnServiceStarted(fn any)

func MD5 added in v0.10.5

func MD5(raw []byte) string

func NotifyStarted added in v0.7.8

func NotifyStarted()

func NotifyStopping added in v0.8.11

func NotifyStopping()

func OnEvent added in v0.8.14

func OnEvent(topic string, fn any)

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 Provide added in v0.5.0

func Provide(constructor ...interface{})

func ProvideStartup added in v0.5.1

func ProvideStartup(constructor ...any)

func ReadEncryptConfig added in v0.8.14

func ReadEncryptConfig(secret []byte, toFile string) error

func ToEmbedConfig added in v0.5.4

func ToEmbedConfig(content []byte, keys ...string)

func ToMd5 added in v0.10.7

func ToMd5(items ...any) string

Types

type Bootup added in v0.5.4

type Bootup struct {
	dig.In
	Secret           ConfigSecret
	EmbedConfigReady EmbedConfigReady
}

type ChanAdaptor added in v0.10.9

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

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]) Start added in v0.10.9

func (ca *ChanAdaptor[T]) Start()

func (*ChanAdaptor[T]) Subscripter added in v0.10.9

func (ca *ChanAdaptor[T]) Subscripter(receiver string) chan T

type ConfigSecret added in v0.8.14

type ConfigSecret []byte

type EmbedConfigReady added in v0.8.17

type EmbedConfigReady interface{}

type Md5Value added in v0.10.7

type Md5Value interface {
	ToMd5() []byte
}

type OptionalParam added in v0.5.7

type OptionalParam[T any] struct {
	dig.In
	P T `optional:"true"`
}

type ServiceParam added in v0.8.3

type ServiceParam struct {
	dig.In
	DB     *gorm.DB
	Logger *zap.Logger
	Bus    EventBus.Bus
}

type Startup added in v0.5.1

type Startup interface{}

type SystenEvent added in v0.8.11

type SystenEvent func()

Jump to

Keyboard shortcuts

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