Documentation
¶
Index ¶
- Constants
- func CheckValue(db *gorm.DB, key, defaultValue, format string, autoload, public bool)
- func GetBoolEnv(key string) bool
- func GetBoolValue(db *gorm.DB, key string) bool
- func GetEnv(key string) string
- func GetFloatEnv(key string) float64
- func GetFloatEnvWithDefault(key string, defaultValue float64) float64
- func GetIntEnv(key string) int64
- func GetIntEnvWithDefault(key string, defaultValue int) int
- func GetIntValue(db *gorm.DB, key string, defaultVal int) int
- func GetValue(db *gorm.DB, key string) string
- func InitGlobalCache(maxSize int, expiration time.Duration)
- func LoadAutoloads(db *gorm.DB)
- func LoadEnv(env string) error
- func LoadEnvs(objPtr any)
- func LookupEnv(key string) (value string, found bool)
- func SetValue(db *gorm.DB, key, value, format string, autoload, public bool)
- type Config
- type ExpiredLRUCache
- type SigHandler
- type SigHandlerEvent
- type SignalHandler
- type Signals
- func (s *Signals) Clear(events ...string)
- func (s *Signals) Connect(event string, handler SignalHandler) uint
- func (s *Signals) DisableAsync(ctx context.Context) error
- func (s *Signals) Disconnect(event string, id uint)
- func (s *Signals) Emit(event string, sender any, params ...any)
- func (s *Signals) EnableAsync(workers, queueSize int, dropOnFull bool) error
- func (s *Signals) SetLogger(lg *zap.Logger)
- func (s *Signals) Shutdown(ctx context.Context) error
- func (s *Signals) Start() error
- func (s *Signals) String() string
- type SignalsOptions
- type Snowflake
Constants ¶
View Source
const ( ENV_CONFIG_CACHE_SIZE = "CONFIG_CACHE_SIZE" ENV_CONFIG_CACHE_EXPIRED = "CONFIG_CACHE_EXPIRED" )
Variables ¶
This section is empty.
Functions ¶
func CheckValue ¶
func GetBoolEnv ¶
func GetFloatEnv ¶
func GetFloatEnvWithDefault ¶
GetFloatEnvWithDefault gets float environment variable with default value
func GetIntEnvWithDefault ¶
GetIntEnvWithDefault gets int environment variable with default value
func InitGlobalCache ¶
func LoadAutoloads ¶
Types ¶
type Config ¶
type Config struct {
ID uint `json:"id" gorm:"primaryKey"`
Key string `json:"key" gorm:"size:128;uniqueIndex"`
Desc string `json:"desc" gorm:"size:200"`
Autoload bool `json:"autoload" gorm:"index"`
Public bool `json:"public" gorm:"index" default:"false"`
Format string `json:"format" gorm:"size:20" default:"text" comment:"json,yaml,int,float,bool,text"`
Value string
CreatedAt time.Time `json:"-" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"-" gorm:"autoUpdateTime"`
}
func LoadPublicConfigs ¶
type ExpiredLRUCache ¶
type ExpiredLRUCache[K comparable, V any] struct { *lru.Cache[K, expiredLRUCacheValue[V]] // contains filtered or unexported fields }
var GlobalCache *ExpiredLRUCache[string, any]
GlobalCache is a global cache instance that supports generic key-value pairs
func NewExpiredLRUCache ¶
func NewExpiredLRUCache[K comparable, V any](size int, expired time.Duration) *ExpiredLRUCache[K, V]
func (*ExpiredLRUCache[K, V]) Add ¶
func (c *ExpiredLRUCache[K, V]) Add(key K, value V) (evicted bool)
func (*ExpiredLRUCache[K, V]) Contains ¶
func (c *ExpiredLRUCache[K, V]) Contains(key K) bool
func (*ExpiredLRUCache[K, V]) Get ¶
func (c *ExpiredLRUCache[K, V]) Get(key K) (value V, ok bool)
func (*ExpiredLRUCache[K, V]) Remove ¶
func (c *ExpiredLRUCache[K, V]) Remove(key K) (present bool)
type SigHandler ¶
type SigHandler struct {
ID uint
Handler SignalHandler
}
type SigHandlerEvent ¶
type SigHandlerEvent struct {
EvType int
SignalName string
SigHandler SigHandler
}
type Signals ¶
type Signals struct {
// contains filtered or unexported fields
}
func NewSignals ¶
func NewSignals() *Signals
func NewSignalsWithOptions ¶
func NewSignalsWithOptions(opt SignalsOptions) *Signals
func (*Signals) Disconnect ¶
func (*Signals) EnableAsync ¶
type SignalsOptions ¶
type Snowflake ¶
type Snowflake struct {
// contains filtered or unexported fields
}
var SnowflakeUtil *Snowflake
func NewSnowflake ¶
Click to show internal directories.
Click to hide internal directories.