Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface { // Type return the component type. Type() string // Init is called by Config to register some function and value to the component instance. Init(key string, ctx libctx.FuncContext, get FuncCptGet, vpr libvpr.FuncViper, vrs libver.Version, log liblog.FuncLog) // DefaultConfig is called by Config.GetDefault. // It must return a slice of byte containing the default json config for this component. DefaultConfig(indent string) []byte // Dependencies is called by Config to define if this component need other component. // Each other component can be call by calling Config.Get Dependencies() []string // SetDependencies allow to customize the dependencies for the current component. // The custom dependencies will replace the default dependencies. // Take care to be sure to include the default dependencies into the custom given as params. SetDependencies(d []string) liberr.Error ComponentViper ComponentEvent ComponentMonitor }
type ComponentEvent ¶
type ComponentEvent interface { // RegisterFuncStart is called to register the function to be called before and after the start function. RegisterFuncStart(before, after FuncCptEvent) // RegisterFuncReload is called to register the function to be called before and after the reload function. RegisterFuncReload(before, after FuncCptEvent) // IsStarted is trigger by the Config interface with function ComponentIsStarted. // This function can be usefull to know if the start server function is still call. IsStarted() bool // IsRunning is trigger by the Config interface with function ComponentIsRunning. // This function can be usefully to know if the component server function is still call. // The atLeast param is used to know if the function must return true on first server is running // or if all server must be running to return true. IsRunning() bool // Start is called by the Config interface when the global configuration as been started // This function can be usefull to start server in go routine with a configuration stored // itself. Start() liberr.Error // Reload is called by the Config interface when the global configuration as been updated // It receives a func as param to grab a config model by sending a model structure. // It must configure itself, and stop / start his server if possible or return an error. Reload() liberr.Error // Stop is called by the Config interface when global context is done. // The context done can arrive by stopping the application or by received a signal KILL/TERM. // This function must stop cleanly the component. Stop() }
type ComponentList ¶
type ComponentList interface { // ComponentHas return true if the key is a registered Component ComponentHas(key string) bool // ComponentType return the Component Type of the registered key. ComponentType(key string) string // ComponentGet return the given component associated with the config Key. // The component can be transTyped to other interface to be exploited ComponentGet(key string) Component // ComponentDel remove the given Component key from the config. ComponentDel(key string) // ComponentSet stores the given Component with a key. ComponentSet(key string, cpt Component) // ComponentList returns a map of stored couple keyType and Component ComponentList() map[string]Component // ComponentWalk run a function on each component ComponentWalk(fct ComponentListWalkFunc) // ComponentKeys returns a slice of stored Component keys ComponentKeys() []string // ComponentStart trigger the Start function of each Component. // This function will keep the dependencies of each Component. // This function will stop the Start sequence on any error triggered. ComponentStart() liberr.Error // ComponentIsStarted will trigger the IsStarted function of all registered component. // If any component return false, this func return false. ComponentIsStarted() bool // ComponentReload trigger the Reload function of each Component. // This function will keep the dependencies of each Component. // This function will stop the Reload sequence on any error triggered. ComponentReload() liberr.Error // ComponentStop trigger the Stop function of each Component. // This function will not keep the dependencies of each Component. ComponentStop() // ComponentIsRunning will trigger the IsRunning function of all registered component. // If asLeast params is false and at least one component return false, this func return false. // Otherwise, if the params is true, if at least one component is true, this func return true. ComponentIsRunning(atLeast bool) bool // DefaultConfig aggregates all registered components' default config // Returns a filled buffer with a complete config json model DefaultConfig() io.Reader // RegisterFlag can be called to register flag to a spf cobra command and link it with viper // to retrieve it into the config viper. // The key will be use to stay config organisation by compose flag as key.config_key. RegisterFlag(Command *spfcbr.Command) error }
type ComponentListWalkFunc ¶
ComponentListWalkFunc is used for ComponentList.Walk. For each component the function is call with the component key and the component as params. If the function return false, the loop is breaking, other else, the loop will run the function until the end of the component list.
type ComponentMonitor ¶
type ComponentViper ¶
type FuncCptEvent ¶
type FuncCptGet ¶
Click to show internal directories.
Click to hide internal directories.