Documentation ¶
Index ¶
- Constants
- Variables
- func FlagDefines()
- func MarshalConfig(lconf *LiveConfig) (conf []byte, err error)
- func SetDefaultLine(line Line)
- func SetLogger(log SLogger)
- func UnMarshalConfig(conf []byte, obj interface{}) (err error)
- type AfterAllIDestroyer
- type AfterAllInjecter
- type AfterAllStarter
- type AllEvent
- type BeforeAllStopper
- type BuildNewer
- type Builder
- type Checker
- type Cmd
- type CmdParameterName
- type Config
- type ConfigTypeLives
- type Creator
- type Destroyer
- type Dot
- type DotConfig
- type Error
- type Errorer
- type Event
- type Eventer
- type Events
- type HotConfig
- type Injected
- type Injecter
- type Level
- type Lifer
- type Line
- type Live
- type LiveConfig
- type LiveEvents
- type LiveId
- type LogConfig
- type MakeStringer
- type Metadata
- type Newer
- type SConfig
- type SLogger
- type SetterLine
- type SetterTypeAndLiveId
- type Starter
- type StatusType
- type Statuser
- type Stopper
- type Tager
- type TypeEvents
- type TypeId
- type TypeLives
Constants ¶
const ( LogLiveId = "d8299d21-4f43-48bd-9a5c-654c4395ea17" // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zapcore.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zapcore.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zapcore.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = zapcore.ErrorLevel // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. FatalLevel = zapcore.FatalLevel )
const (
SconfigTypeId = "484ef01d-3c04-4517-a643-2d776a9ae758"
)
const (
//TagDot tag dot
TagDot = "dot"
)
Variables ¶
var SError = &Error{}
SError error object frequently used by dot
Functions ¶
func MarshalConfig ¶
func MarshalConfig(lconf *LiveConfig) (conf []byte, err error)
func SetLogger ¶
func SetLogger(log SLogger)
Set default log, This method does not consider thread security, Adjusting value is not suggested after program initialization
func UnMarshalConfig ¶
Types ¶
type AfterAllIDestroyer ¶
type AfterAllIDestroyer interface {
AfterAllIDestroy(l Line)
}
After all destroy, before builder AfterDestroy
type AfterAllInjecter ¶
type AfterAllInjecter interface {
AfterAllInject(l Line)
}
After all inject, before builder AfterStart
type AfterAllStarter ¶
type AfterAllStarter interface {
AfterAllStart(l Line)
}
After all start, before builder AfterStart
type BeforeAllStopper ¶
type BeforeAllStopper interface {
BeforeAllStop(l Line)
}
Call before all stop, after Builder BeforeStop
type BuildNewer ¶
Add typeid, newer for dot in config file This function is run after line create, also you can add other initialized content
type Builder ¶
type Builder struct { Add BuildNewer BeforeCreate AllEvent //Before all dot create AfterCreate AllEvent //after all dot create BeforeStart AllEvent //Before all dot start AfterStart AllEvent //After all dot start BeforeStop AllEvent //Before all dot stop AfterStop AllEvent //After all dot stop BeforeDestroy AllEvent //Before all dot destroy AfterDestroy AllEvent //After all dot destroy LineLiveId string //line unique id, default value is “default” }
type Checker ¶
type Checker interface {
Check(args interface{}) interface{}
}
Checker Check dot,run some verification or test data, return the result
type Cmd ¶
type Cmd struct { //ConfigPath config file path ConfigPath string //ConfigFile config file name without path ConfigFile string }
Cmd type general command line parameters
var GCmd Cmd
GCmd Global variables general command line parameters
type CmdParameterName ¶
type CmdParameterName string
CmdParameterName Command line parameter name
const ( //Config file path, add Cmd to show relations with struct cmd CmdConfigPath CmdParameterName = "configpath" //Config file name without path CmdConfigFile CmdParameterName = "configfile" )
Command line parameters
func (CmdParameterName) String ¶
func (c CmdParameterName) String() string
type Config ¶
Config config
func (*Config) FindConfig ¶
func (c *Config) FindConfig(tid TypeId, live LiveId) *LiveConfig
FindConfig find config
type ConfigTypeLives ¶
type ConfigTypeLives struct { TypeIdConfig TypeId `json:"typeId"` ConfigInfo interface{} `json:"json"` }
jayce edit config json
type DotConfig ¶
type DotConfig struct { MetaData Metadata `json:"metaData"` Lives []LiveConfig `json:"lives"` }
DotConfig dot config
type Error ¶
type Error struct { NilParameter Errorer Existed Errorer NotExisted Errorer Parameter Errorer RelyTypeNotMatch Errorer TypeIdEmpty Errorer Config Errorer NoDotNewer Errorer NotStruct Errorer DotInvalid Errorer }
Error dot error
type Eventer ¶
type Eventer interface { // ReSetLiveEvents(lid LiveId, liveEvents *LiveEvents) // AddLiveEvents(lid LiveId, liveEvents *LiveEvents) // LiveEvents(lid LiveId) []LiveEvents // ReSetTypeEvents(tid TypeId, typeEvents *TypeEvents) // AddTypeEvents(tid TypeId, typeEvents *TypeEvents) // TypeEvents(tid TypeId) []TypeEvents }
Eventer
type Events ¶
type Events struct { //Before the dot create BeforeCreate Event //after the dot create AfterCreate Event //Before the dot start BeforeStart Event //After the dot start AfterStart Event //Before the dot stop BeforeStop Event //After the dot stop AfterStop Event //Before the dot destroy BeforeDestroy Event //After the dot destroy AfterDestroy Event }
Events
type HotConfig ¶
type HotConfig interface { //Update Update config info, return true means successful HotConfig(newConf SConfig) bool }
HotConfig hot change config
type Injecter ¶
type Injecter interface { //Inject inject //obj only support structure //dot.TagDot (dot) tag is in the field //If tag is empty, then input with field type, otherwise input with tag value(dot.LiveId) //In the process if error occurred, it will not quit, returned error is the first one occurred Inject(obj interface{}) error //GetByType get by type //If no related object in current container, then will call parent to search //type container is seperate with liveid container GetByType(t reflect.Type) (d Dot, err error) //GetByLiveId get by liveid //If no related object in current container, then will call parent to search //type container is seperate with liveid container GetByLiveId(id LiveId) (d Dot, err error) //ReplaceOrAddByType update //Cannot operate parent ReplaceOrAddByType(d Dot) error //Cannot operate parent ReplaceOrAddByParamType(d Dot, t reflect.Type) error //ReplaceOrAddByLiveId update //Cannot operate parent ReplaceOrAddByLiveId(d Dot, id LiveId) error //RemoveByType remove RemoveByType(t reflect.Type) error //RemoveByLiveId remove RemoveByLiveId(id LiveId) error //SetParent set parent injecter SetParent(p Injecter) //GetParent get parent injecter GetParent() Injecter }
type Lifer ¶
Lifer life cycle Create, Start,Stop,Destroy Create and Start are separate, in order to resolve the dependencies between different dot instances, if there is no problem with the dependencies, then you can directly null in Start All methods of Lifer cannot be stucked while running, now the realization of line is sync call
type Line ¶
type Line interface { //Return unique Line name Id() string //Line API Config() *Config //SConfig general config API SConfig() SConfig SLogger() SLogger //order //1,Search liveid corresponding newer //2,Search typid corresponding newer //3,Search right newer in meta //AddNewerByLiveId add new for liveid AddNewerByLiveId(liveid LiveId, newDot Newer) error //AddNewerByTypeId add new for type AddNewerByTypeId(typeid TypeId, newDot Newer) error //RemoveNewerByLiveId remove RemoveNewerByLiveId(liveid LiveId) //RemoveNewerByTypeId remove RemoveNewerByTypeId(typeid TypeId) //PreAdd Add dot liveid and meta info, here no dot is created, it will be generated after Computing dependence //If it is the single sample, don't need to point sample info, sample id is typeid //If config file has config sample, then it will be added automatically, if sample id already existing, then config is prior PreAdd(typeLives ...*TypeLives) error //RelyOrder Check whether dependency existing //RelyOrder() error ////CreateDots create dots //CreateDots() error //ToLifer to lifer ToLifer() Lifer //ToInjecter to injecter ToInjecter() Injecter //ToDotEventer to Eventer ToDotEventer() Eventer //GetDotConfig get GetDotConfig(liveid LiveId) *LiveConfig GetLineBuilder() *Builder //InfoAllTypeAdnLives just for debug, log info all types and lives InfoAllTypeAdnLives() }
Line line
func GetDefaultLine ¶
func GetDefaultLine() Line
Return default Line,general program only has one line
type Live ¶
type Live struct { TypeId TypeId `json:"typeId"` LiveId LiveId `json:"liveId"` RelyLives map[string]LiveId `json:"relyLives"` Dot Dot `json:"-"` }
Live live/instance
type LiveConfig ¶
type LiveConfig struct { //LiveId LiveId LiveId `json:"liveId"` //RelyLives rely lives, If cannot confirm key value then key value is livid value RelyLives map[string]LiveId `json:"relyLives"` //Json json Json *json.RawMessage `json:"json"` }
LiveConfig live config
type LiveEvents ¶
type LiveEvents = Events
type Metadata ¶
type Metadata struct { TypeId TypeId `json:"typeId"` Version string `json:"version"` Name string `json:"name"` ShowName string `json:"showName"` Single bool `json:"single"` RelyTypeIds []TypeId `json:"relyTypeIds"` NewDoter Newer `json:"-"` RefType reflect.Type `json:"-"` }
Metadata dot metadata
type SConfig ¶
type SConfig interface { //RootPath root path RootPath() //Config file path ConfigPath() string //Without path, only file name ConfigFile() string //Whether key existing Key(key string) bool //If no config or config is empty, return nil Map() (m map[string]interface{}, err error) //Priorly bring data from RAM and operate, if RAM is nil then check whether original config file existing Unmarshal(s interface{}) error //Analyze key is corresponding type UnmarshalKey(key string, obj interface{}) error Marshal(data []byte) error //If no corresponding key or data type cannot be converted, must pay attention to default value, so add "Def" before function to notify default value DefInterface(key string, def interface{}) interface{} DefArray(key string, def []interface{}) []interface{} DefMap(key string, def map[string]interface{}) map[string]interface{} DefString(key string, def string) string DefInt32(key string, def int32) int32 DefUint32(key string, def uint32) uint32 DefInt64(key string, def int64) int64 DefUint64(key string, def uint64) uint64 DefBool(key string, def bool) bool DefFloat32(key string, def float32) float32 DefFloat64(key string, def float64) float64 }
SConfig config belongs to one component Dot, but it is so basic, every Dot need it, so define it in dot.go file S represents scryinfo config this name is used frequently, so add s to distinguish it
type SLogger ¶
type SLogger interface { //GetLevel get level GetLevel() Level //SetLevel set level SetLevel(level Level) //Debugf debug //Debugf(format string, args ...interface{}) //Debugln debug Debugln(msg string, fields ...zap.Field) //Debug debug Debug(mstr MakeStringer) //Infof info //Infof(format string, args ...interface{}) //Infoln info Infoln(msg string, fields ...zap.Field) //Info info Info(mstr MakeStringer) //Warnf warn //Warnf(format string, args ...interface{}) //Warnln warn Warnln(msg string, fields ...zap.Field) //Warn warn Warn(mstr MakeStringer) //Errorf error //Errorf(format string, args ...interface{}) //Errorln error Errorln(msg string, fields ...zap.Field) //Error error Error(mstr MakeStringer) //Fatalf fatal //Fatalf(format string, args ...interface{}) //Fatalln fatal Fatalln(msg string, fields ...zap.Field) //Fatal fatal Fatal(mstr MakeStringer) //NewLogger return new logger NewLogger(callerSkip int) SLogger }
SLogger log belongs to one component Dot, but it is too basic, most Dot need it, so defined it to dot.go file All log calling should not call function in parameters, function run priorly than log, if must call function, you should use callback(must run normally) S represents scryinfo, log name used frequently so add s to distinguish it
func Logger ¶
func Logger() SLogger
Return default log, this API is used to call log easily This method does not consider thread security, Adjusting value is not suggested after program initialization Note: Default log, if log is not created, then returned log will be output to control panel, all log will be output
type SetterLine ¶
type SetterLine interface {
SetLine(l Line)
}
If component need to know current line, then realize this API, and this API Will be called before component Create
type SetterTypeAndLiveId ¶
If component need to know current TypeId or LiveId, then realize this API, and this API Will be called before component Create
type Tager ¶
type Tager interface { //SetTag set tag SetTag(tag interface{}) //GetTag get tag GetTag() (tag interface{}) }
Tager dot signature data, used by dot
type TypeEvents ¶
type TypeEvents = Events