Documentation ¶
Index ¶
- Variables
- type Action
- type ActionDelegateFunc
- type ActionHandler
- type ActionParams
- type BrokerContext
- type BrokerContextFunc
- type BrokerDelegates
- type BusFunc
- type Config
- type Context
- type CreatedFunc
- type EmitEventFunc
- type Event
- type EventHandler
- type ForEachFunc
- type InstanceIDFunc
- type LifecycleFunc
- type LocalNodeFunc
- type LogFormatType
- type LogLevelType
- type LoggerFunc
- type MiddlewareHandler
- type MiddlewareHandlerFunc
- type Middlewares
- type Mixin
- type MultActionDelegateFunc
- type Node
- type ObjectSchema
- type Options
- type Payload
- type PublishServicesFunc
- type RetryPolicy
- type SerializerType
- type ServiceForActionFunc
- type ServiceSchema
- type StrategyFactoryFunc
- type StrategyType
- type TransporterFactoryFunc
- type WaitForFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{ Namespace: "", LogLevel: LogLevelInfo, LogFormat: LogFormatText, Serializer: SerializerJSON, DiscoverNodeID: discoverNodeID, Transporter: "MEMORY", Strategy: StrategyRandom, HeartbeatFrequency: 5 * time.Second, HeartbeatTimeout: 15 * time.Second, OfflineCheckFrequency: 20 * time.Second, OfflineTimeout: 10 * time.Minute, DontWaitForNeighbours: true, NeighboursCheckTimeout: 2 * time.Second, WaitForDependenciesTimeout: 2 * time.Second, Metrics: false, MetricsRate: 1, DisableInternalServices: false, DisableInternalMiddlewares: false, Created: func() {}, Started: func() {}, Stopped: func() {}, MaxCallLevel: 100, RetryPolicy: RetryPolicy{ Enabled: false, }, RequestTimeout: 3 * time.Second, MCallTimeout: 5 * time.Second, WaitForNeighboursInterval: 200 * time.Millisecond, }
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { Name string Handler ActionHandler Params ActionParams Settings map[string]interface{} Description string }
type ActionDelegateFunc ¶
type ActionDelegateFunc func(context BrokerContext, opts ...Options) chan Payload
type ActionHandler ¶
type ActionParams ¶
type ActionParams interface { }
ActionSchema is used by the validation engine to check if parameters sent to the action are valid.
type BrokerContext ¶
type BrokerContext interface { Call(actionName string, params interface{}, opts ...Options) chan Payload Emit(eventName string, params interface{}, groups ...string) ChildActionContext(actionName string, params Payload, opts ...Options) BrokerContext ChildEventContext(eventName string, params Payload, groups []string, broadcast bool) BrokerContext ActionName() string EventName() string Payload() Payload Groups() []string IsBroadcast() bool Caller() string //export context info in a map[string] AsMap() map[string]interface{} SetTargetNodeID(targetNodeID string) TargetNodeID() string ID() string RequestID() string Meta() Payload UpdateMeta(Payload) Logger() *log.Entry Publish(...interface{}) WaitFor(services ...string) error }
type BrokerContextFunc ¶
type BrokerContextFunc func() BrokerContext
type BrokerDelegates ¶
type BrokerDelegates struct { InstanceID InstanceIDFunc LocalNode LocalNodeFunc Logger LoggerFunc Bus BusFunc IsStarted isStartedFunc Config Config MultActionDelegate MultActionDelegateFunc ActionDelegate ActionDelegateFunc EmitEvent EmitEventFunc BroadcastEvent EmitEventFunc HandleRemoteEvent EmitEventFunc ServiceForAction ServiceForActionFunc BrokerContext BrokerContextFunc MiddlewareHandler MiddlewareHandlerFunc PublishServices PublishServicesFunc WaitFor WaitForFunc }
type Config ¶
type Config struct { LogLevel LogLevelType LogFormat LogFormatType Serializer SerializerType DiscoverNodeID func() string Transporter string TransporterFactory TransporterFactoryFunc Strategy StrategyType StrategyFactory StrategyFactoryFunc HeartbeatFrequency time.Duration HeartbeatTimeout time.Duration OfflineCheckFrequency time.Duration OfflineTimeout time.Duration NeighboursCheckTimeout time.Duration WaitForDependenciesTimeout time.Duration Middlewares []Middlewares Namespace string RequestTimeout time.Duration MCallTimeout time.Duration RetryPolicy RetryPolicy MaxCallLevel int Metrics bool MetricsRate float32 DisableInternalServices bool DisableInternalMiddlewares bool DontWaitForNeighbours bool WaitForNeighboursInterval time.Duration Created func() Started func() Stopped func() Services map[string]interface{} }
type Context ¶
type Context interface { //context methods used by services MCall(map[string]map[string]interface{}) chan map[string]Payload Call(actionName string, params interface{}, opts ...Options) chan Payload Emit(eventName string, params interface{}, groups ...string) Broadcast(eventName string, params interface{}, groups ...string) Logger() *log.Entry Payload() Payload Meta() Payload }
type CreatedFunc ¶
type CreatedFunc func(ServiceSchema, *log.Entry)
type EmitEventFunc ¶
type EmitEventFunc func(context BrokerContext)
type Event ¶
type Event struct { Name string Group string Handler EventHandler }
type EventHandler ¶
type ForEachFunc ¶
type InstanceIDFunc ¶
type InstanceIDFunc func() string
type LifecycleFunc ¶
type LifecycleFunc func(BrokerContext, ServiceSchema)
type LocalNodeFunc ¶
type LocalNodeFunc func() Node
type LogFormatType ¶
type LogFormatType string
const ( LogFormatJSON LogFormatType = "JSON" LogFormatText LogFormatType = "TEXT" )
type LogLevelType ¶
type LogLevelType string
const ( LogLevelInfo LogLevelType = "INFO" LogLevelWarn LogLevelType = "WARN" LogLevelError LogLevelType = "ERROR" LogLevelFatal LogLevelType = "FATAL" LogLevelTrace LogLevelType = "TRACE" LogLevelDebug LogLevelType = "DEBUG" )
type MiddlewareHandler ¶
type MiddlewareHandler func(params interface{}, next func(...interface{}))
type MiddlewareHandlerFunc ¶
type MiddlewareHandlerFunc func(name string, params interface{}) interface{}
type Middlewares ¶
type Middlewares map[string]MiddlewareHandler
type Mixin ¶
type Mixin struct { Name string Dependencies []string Settings map[string]interface{} Metadata map[string]interface{} Hooks map[string]interface{} Actions []Action Events []Event Created CreatedFunc Started LifecycleFunc Stopped LifecycleFunc }
type MultActionDelegateFunc ¶
type ObjectSchema ¶
type ObjectSchema struct {
Source interface{}
}
type Payload ¶
type Payload interface { First() Payload Sort(field string) Payload Remove(fields ...string) Payload AddItem(value interface{}) Payload Add(field string, value interface{}) Payload AddMany(map[string]interface{}) Payload MapArray() []map[string]interface{} RawMap() map[string]interface{} Bson() bson.M BsonArray() bson.A Map() map[string]Payload Exists() bool IsError() bool Error() error ErrorPayload() Payload Value() interface{} ValueArray() []interface{} Int() int IntArray() []int Int64() int64 Int64Array() []int64 Uint() uint64 UintArray() []uint64 Float32() float32 Float32Array() []float32 Float() float64 FloatArray() []float64 String() string StringArray() []string Bool() bool BoolArray() []bool ByteArray() []byte Time() time.Time TimeArray() []time.Time Array() []Payload At(index int) Payload Len() int Get(path string, defaultValue ...interface{}) Payload //Only return a payload containing only the field specified Only(path string) Payload IsArray() bool IsMap() bool ForEach(iterator func(key interface{}, value Payload) bool) MapOver(tranform func(in Payload) Payload) Payload }
Payload contains the data sent/return to actions. I has convinience methods to read action parameters by name with the right type.
type PublishServicesFunc ¶
type PublishServicesFunc func(...interface{})
type RetryPolicy ¶
type SerializerType ¶ added in v0.1.2
type SerializerType string
const (
SerializerJSON SerializerType = "JSON"
)
type ServiceForActionFunc ¶
type ServiceForActionFunc func(string) []*ServiceSchema
type ServiceSchema ¶
type ServiceSchema struct { Name string Version string Dependencies []string Settings map[string]interface{} Metadata map[string]interface{} Hooks map[string]interface{} Mixins []Mixin Actions []Action Events []Event Created CreatedFunc Started LifecycleFunc Stopped LifecycleFunc }
type StrategyFactoryFunc ¶
type StrategyFactoryFunc func() interface{}
type StrategyType ¶ added in v0.1.2
type StrategyType string
const ( StrategyRoundRobin StrategyType = "RoundRobin" StrategyRandom StrategyType = "Random" )
type TransporterFactoryFunc ¶
type TransporterFactoryFunc func() interface{}
type WaitForFunc ¶
Directories ¶
Path | Synopsis |
---|---|
Dump from https://github.com/moleculer-go/goemitter/blob/master/goemitter.go
|
Dump from https://github.com/moleculer-go/goemitter/blob/master/goemitter.go |
examples
|
|
Click to show internal directories.
Click to hide internal directories.