Documentation
ΒΆ
Index ΒΆ
- type Event
- type EventResponse
- type EventType
- type FactoryPlugin
- type Manager
- func (m *Manager) Autoload(prefix string, extensionpath ...string) *Manager
- func (m *Manager) Load(extname ...string) *Manager
- func (m *Manager) Publish(event EventType, obj interface{}) (*Manager, error)
- func (m *Manager) Register() *Manager
- func (m *Manager) Response(event EventType, listener ...func(p *Plugin, r *EventResponse)) *Manager
- func (m *Manager) Subscribe(b *emission.Emitter) *Manager
- type Plugin
- type PluginFactory
- type PluginHandler
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Event ΒΆ
type Event struct { Name EventType `json:"name"` Data string `json:"data"` File string `json:"file"` // If Data >> 10K write content to file instead }
Event describes the event structure. Contains a Name field and a Data field which is marshalled in JSON
func NewEvent ΒΆ
NewEvent returns a new event which can be used for publishing the obj gets automatically serialized in json.
func (Event) ResponseEventName ΒΆ
type EventResponse ΒΆ
type EventResponse struct { State string `json:"state"` Data string `json:"data"` Error string `json:"error"` Logs string `json:"log"` }
EventResponse describes the event response structure It represent the JSON response from plugins
func (EventResponse) Errored ΒΆ
func (r EventResponse) Errored() bool
Errored returns true if the response contains an error
func (EventResponse) Unmarshal ΒΆ
func (r EventResponse) Unmarshal(i interface{}) error
Unmarshal decodes the json payload in the given parameteer
type FactoryPlugin ΒΆ
type FactoryPlugin struct { EventType EventType PluginHandler PluginHandler }
type Manager ΒΆ
Manager describes a set of Plugins and a set of Event types which are subscribed to a message bus
func NewManager ΒΆ
NewManager returns a manager instance with a new bus and
func (*Manager) Autoload ΒΆ
Autoload automatically loads plugins binaries prefixed by 'prefix' in the current path optionally takes a list of paths to look also into
func (*Manager) Load ΒΆ
Load finds the binaries given as parameter (without path) and scan the system $PATH to retrieve those automatically
func (*Manager) Publish ΒΆ
Publish is a wrapper around NewEvent and the Manager internal Bus publishing system It accepts optionally a list of functions that are called with the plugin result (only once)
type Plugin ΒΆ
Plugin describes binaries to be hooked on events, with common js input, and common js output
type PluginFactory ΒΆ
type PluginFactory map[EventType]PluginHandler
PluginFactory is a collection of handlers for a given event type. a plugin has to respond to multiple events and it always needs to return an Event response as result
func NewPluginFactory ΒΆ
func NewPluginFactory(p ...FactoryPlugin) PluginFactory
func (PluginFactory) Add ΒΆ
func (p PluginFactory) Add(ev EventType, ph PluginHandler)
Add associates an handler to an event type
type PluginHandler ΒΆ
type PluginHandler func(*Event) EventResponse
PluginHandler represent a generic plugin which talks go-pluggable API It receives an event, and is always expected to give a response