Documentation
¶
Index ¶
- func RegisterParser(parser IDataParser)
- func RegisterSource(dataSource IDataSource)
- type ConfigChangeFn
- type DataConfigComponent
- func (d *DataConfigComponent) GetBytes(configName string) (data []byte, found bool)
- func (d *DataConfigComponent) GetDataSource() IDataSource
- func (d *DataConfigComponent) GetIConfigFile(name string) IConfig
- func (d *DataConfigComponent) GetParser() IDataParser
- func (d *DataConfigComponent) Init()
- func (d *DataConfigComponent) Name() string
- func (d *DataConfigComponent) OnStop()
- func (d *DataConfigComponent) Register(configs ...IConfig)
- type IConfig
- type IDataConfig
- type IDataParser
- type IDataSource
- type ParserJson
- type SourceFile
- type SourceRedis
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterParser ¶
func RegisterParser(parser IDataParser)
func RegisterSource ¶
func RegisterSource(dataSource IDataSource)
Types ¶
type ConfigChangeFn ¶
ConfigChangeFn 数据变更时触发该函数
type DataConfigComponent ¶
type DataConfigComponent struct {
sync.RWMutex
cherryFacade.Component
// contains filtered or unexported fields
}
func NewComponent ¶
func NewComponent() *DataConfigComponent
func (*DataConfigComponent) GetBytes ¶
func (d *DataConfigComponent) GetBytes(configName string) (data []byte, found bool)
func (*DataConfigComponent) GetDataSource ¶
func (d *DataConfigComponent) GetDataSource() IDataSource
func (*DataConfigComponent) GetIConfigFile ¶
func (d *DataConfigComponent) GetIConfigFile(name string) IConfig
func (*DataConfigComponent) GetParser ¶
func (d *DataConfigComponent) GetParser() IDataParser
func (*DataConfigComponent) Init ¶
func (d *DataConfigComponent) Init()
func (*DataConfigComponent) Name ¶
func (d *DataConfigComponent) Name() string
Name unique components name
func (*DataConfigComponent) OnStop ¶
func (d *DataConfigComponent) OnStop()
func (*DataConfigComponent) Register ¶
func (d *DataConfigComponent) Register(configs ...IConfig)
type IConfig ¶
type IConfig interface {
Name() string // 配置名称
Load(maps interface{}, reload bool) error // 配置序列化后,执行该函数
}
IConfig 配置接口
type IDataConfig ¶
type IDataConfig interface {
Register(configFile ...IConfig) // 注册映射文件
GetBytes(configName string) (data []byte, found bool) // 获取原始的数据
GetParser() IDataParser // 当前参数配置的数据格式解析器
GetDataSource() IDataSource // 当前参数配置的获取数据源
}
IDataConfig 数据配置接口
type IDataParser ¶
type IDataParser interface {
TypeName() string // 注册名称
Unmarshal(text []byte, v interface{}) error // 文件格式解析器
}
IDataParser 数据格式解析接口
func GetParser ¶
func GetParser(name string) IDataParser
type IDataSource ¶
type IDataSource interface {
Name() string // 数据源名称
Init(dataConfig IDataConfig) // 函数初始化时
ReadBytes(configName string) (data []byte, error error) // 获取数据流
OnChange(fn ConfigChangeFn) // 数据变更时
Stop() // 停止
}
IDataSource 配置文件数据源
func GetDataSource ¶
func GetDataSource(name string) IDataSource
type ParserJson ¶
type ParserJson struct {
}
func (*ParserJson) TypeName ¶
func (j *ParserJson) TypeName() string
func (*ParserJson) Unmarshal ¶
func (j *ParserJson) Unmarshal(data []byte, v interface{}) error
type SourceFile ¶
type SourceFile struct {
// contains filtered or unexported fields
}
SourceFile 本地读取数据配置文件
func (*SourceFile) Init ¶
func (f *SourceFile) Init(_ IDataConfig)
func (*SourceFile) Name ¶
func (f *SourceFile) Name() string
func (*SourceFile) OnChange ¶
func (f *SourceFile) OnChange(fn ConfigChangeFn)
func (*SourceFile) ReadBytes ¶
func (f *SourceFile) ReadBytes(configName string) (data []byte, error error)
func (*SourceFile) Stop ¶
func (f *SourceFile) Stop()
type SourceRedis ¶
type SourceRedis struct {
}
func (*SourceRedis) Init ¶
func (r *SourceRedis) Init(_ IDataConfig)
func (*SourceRedis) Name ¶
func (r *SourceRedis) Name() string
func (*SourceRedis) OnChange ¶
func (r *SourceRedis) OnChange(fn ConfigChangeFn)
func (*SourceRedis) ReadBytes ¶
func (r *SourceRedis) ReadBytes(configName string) (data []byte, error error)
func (*SourceRedis) Stop ¶
func (r *SourceRedis) Stop()
Click to show internal directories.
Click to hide internal directories.