Documentation ¶
Index ¶
- Constants
- Variables
- func Handle(c any) error
- func HandleDefault(c any) error
- func HandleWith[C any](c C) (C, error)
- func LoggerErrorCallback(logger *log.Logger) func(err *Error)
- func MustHandleWith[C any](c C) C
- func PostHandle(c any) error
- func PreHandle(c any) error
- type ConfigReloadChecker
- type Context
- func (c *Context[C]) Config() *C
- func (c *Context[C]) InitConfig() error
- func (c *Context[C]) RegisterConfigReloadChecker(checker ConfigReloadChecker[C]) uint64
- func (c *Context[C]) RegisterConfigReloadedCallback(callback OnConfigReloaded[C]) uint64
- func (c *Context[C]) ReloadConfig() error
- func (c *Context[C]) UnregisterConfigReloadChecker(id uint64)
- func (c *Context[C]) UnregisterConfigReloadedCallback(id uint64)
- type Error
- type ErrorType
- type OnConfigReloaded
- type Option
- func AddBytes[C any](bs []byte, typ Type) Option[C]
- func AddFile[C any](path string, typ *Type) Option[C]
- func AddFilePrefix[C any](prefix string, types ...Type) Option[C]
- func ErrorCallback[C any](callback func(err *Error)) Option[C]
- func SetBytes[C any](bs []byte, typ Type) Option[C]
- func SetFile[C any](path string, typ *Type) Option[C]
- func SetFilePrefix[C any](prefix string, types ...Type) Option[C]
- type Parser
- func (p *Parser) AddBytes(bs []byte, typ Type)
- func (p *Parser) AddFile(path string, typ *Type)
- func (p *Parser) AddFilePrefix(prefix string, types ...Type)
- func (p *Parser) SetBytes(bs []byte, typ Type)
- func (p *Parser) SetFile(path string, typ *Type)
- func (p *Parser) SetFilePrefix(prefix string, types ...Type)
- func (p *Parser) Unmarshal(c interface{}) error
- type PostHandleAfterChildrenConfig
- type PostHandlerConfig
- type PostModifyAfterChildrenConfig
- type PostModifyConfig
- type PreHandleAfterChildrenConfig
- type PreHandlerConfig
- type PreModifyAfterChildrenConfig
- type PreModifyConfig
- type Type
Constants ¶
View Source
const ( // ParseError occurs when an error occurs in the configuration parsing ParseError = ErrorType(iota) // CheckError occurs when an error occurs in the configuration checking CheckError // ReloadParseError occurs when an error occurs in the configuration // reloaded and parsing ReloadParseError // ReloadCheckError occurs when an error occurs in the configuration // reloaded and checking ReloadCheckError )
View Source
const MaxConfigFileSize = 32 * 1024 * 1024
Variables ¶
View Source
var ( TypeUnknown = Type{Id: id.Uint64Id(&typeIdCxt), Name: "unknown"} TypeYaml = Type{Id: id.Uint64Id(&typeIdCxt), Name: "yaml", Suffixes: []string{"yaml", "yml"}, Unmarshaler: yaml.Unmarshal} TypeJson = Type{Id: id.Uint64Id(&typeIdCxt), Name: "json", Suffixes: []string{"json"}, Unmarshaler: json.Unmarshal} )
View Source
var ConfigSizeTooLargeError = fmt.Errorf("配置文件大小过大,超过限定大小(%s)", unit.Size(MaxConfigFileSize))
Functions ¶
func HandleDefault ¶
func HandleWith ¶
func LoggerErrorCallback ¶
func MustHandleWith ¶
func MustHandleWith[C any](c C) C
func PostHandle ¶
Types ¶
type ConfigReloadChecker ¶
type Context ¶
func NewContext ¶
func (*Context[C]) InitConfig ¶
func (*Context[C]) RegisterConfigReloadChecker ¶
func (*Context[C]) RegisterConfigReloadedCallback ¶
func (c *Context[C]) RegisterConfigReloadedCallback(callback OnConfigReloaded[C]) uint64
func (*Context[C]) ReloadConfig ¶
func (*Context[C]) UnregisterConfigReloadChecker ¶
func (*Context[C]) UnregisterConfigReloadedCallback ¶
type OnConfigReloaded ¶
type OnConfigReloaded[C any] func(oc, nc *C)
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) AddFilePrefix ¶
func (*Parser) SetFilePrefix ¶
type PostHandleAfterChildrenConfig ¶
type PostHandleAfterChildrenConfig interface {
PostHandleAfterChildren() error
}
type PostHandlerConfig ¶
type PostHandlerConfig interface {
PostHandle() error
}
type PostModifyConfig ¶
type PreHandleAfterChildrenConfig ¶
type PreHandleAfterChildrenConfig interface {
PreHandleAfterChildren()
}
type PreHandlerConfig ¶
type PreHandlerConfig interface {
PreHandle()
}
type PreModifyConfig ¶
Click to show internal directories.
Click to hide internal directories.