Documentation ¶
Index ¶
- Constants
- type Collector
- type Container
- type Endure
- func (e *Endure) Init() error
- func (e *Endure) Initialize() error
- func (e *Endure) Register(vertex interface{}) error
- func (e *Endure) RegisterAll(plugins ...interface{}) error
- func (e *Endure) Serve() (<-chan *Result, error)
- func (e *Endure) Shutdown() error
- func (e *Endure) Start() (<-chan *Result, error)
- func (e *Endure) Stop() error
- func (e *Endure) Visualize(vertices []*vertex.Vertex) error
- type Level
- type Named
- type Options
- type Output
- type Provide
- type Provider
- type Providers
- type Result
- type Service
Constants ¶
const ( // InitializeMethodName is the method fn to invoke in transition map InitializeMethodName = "Initialize" // StartMethodName is the method fn to invoke in transition map StartMethodName = "Start" // ShutdownMethodName is the method fn to invoke in transition map ShutdownMethodName = "Shutdown" )
const InitMethodName = "Init"
InitMethodName is the function fn for the reflection
const ServeMethodName = "Serve"
ServeMethodName is the function fn for the Serve
const StopMethodName = "Stop"
StopMethodName is the function fn for the reflection to Stop the service
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector interface {
// Collects search for the structures or (and) interfaces in the arguments and provides it for the plugin
Collects() []interface{}
}
Collector declares the ability to accept the plugins which match the provided method signature.
type Container ¶
type Container interface { // Serve used to Start the plugin in topological order Serve() (<-chan *Result, error) // Stop stops the plugins in rev-topological order Stop() error // Register registers one plugin in container Register(service interface{}) error // RegisterAll register set of comma separated plugins in container RegisterAll(service ...interface{}) error // Init initializes all plugins (calling Init function), calculate vertices, invoke Collects and Provided functions if exist Init() error }
Container - Internal container interface
type Endure ¶
Endure struct represent main endure repr
func NewContainer ¶
NewContainer returns empty endure container Input parameters: logLevel
-1 is the most informative level - DebugLevel --> also turns on pprof endpoint 0 - InfoLevel defines info log level. 1 - 2 - WarnLevel defines warn log level. 3 - ErrorLevel defines error log level. 4 - FatalLevel defines fatal log level. 5 - PanicLevel defines panic log level. 6 - NoLevel defines an absent log level. 7 - Disabled disables the logger. see the endure.Level
func (*Endure) Initialize ¶
Initialize used to add edges between vertices, sort graph topologically Do not change this method fn, sync with constants in the beginning of this file
func (*Endure) Register ¶
Register registers the dependencies in the Endure graph without invoking any methods
func (*Endure) RegisterAll ¶
RegisterAll is the helper for the register to register more than one structure in the endure
func (*Endure) Serve ¶
Serve starts serving the graph This is the initial serveInternal, if error produced immediately in the initial serveInternal, endure will traverse deps back, call internal_stop and exit
func (*Endure) Shutdown ¶
Shutdown used to shutdown the Endure Do not change this method fn, sync with constants in the beginning of this file
func (*Endure) Start ¶
Start used to start serving vertices Do not change this method fn, sync with constants in the beginning of this file
type Level ¶
type Level int8
A Level is a logging priority. Higher levels are more important.
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel Level = iota - 1 // InfoLevel is the default logging priority. InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel // PanicLevel logs a message, then panics. PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel )
type Named ¶
type Named interface { // Name return user friendly name of the plugin Name() string }
Named -> Name of the service
type Options ¶
type Options func(endure *Endure)
Options is the endure options
func GracefulShutdownTimeout ¶
GracefulShutdownTimeout sets the timeout to kill the vertices is one or more of them are frozen
func RetryOnFail ¶
RetryOnFail if set to true, endure will try to stop and restart graph if one or more vertices are failed
func SetBackoff ¶
SetBackoff sets initial and maximum backoff interval for retry
func SetLogLevel ¶
SetLogLevel option sets the log level in the Endure
type Provide ¶
type Provide struct { In []reflect.Type Out []reflect.Type // contains filtered or unexported fields }
Provide struct represents a single Provide value, which consists of: 1. m -> method reflected value 2. In -> In types (fn foo(a int, b int)) 3. Out -> returning types (fn boo() a int, b int)
type Provider ¶
type Provider interface {
// Provides function return set of functions which provided dependencies to other plugins
Provides() []interface{}
}
Provider declares the ability to provide service edges of declared types.