Documentation ¶
Index ¶
- Variables
- type Args
- type Client
- type Decoder
- type Encoder
- type Error
- type Event
- type Format
- type FormatFactory
- type Handler
- type HandlerFunc
- type Manager
- func (ph Manager) Dispatch(e Event, args Args) error
- func (ph *Manager) Handle(pl Plugin)
- func (ph *Manager) HandleAll(pls ...Plugin)
- func (ph Manager) Handler() Handler
- func (ph *Manager) ListenAndServe() error
- func (ph Manager) Muxer() Muxer
- func (ph *Manager) SetHandler(h Handler)
- func (ph *Manager) Unhandle(pl Plugin)
- type Muxer
- type Plugin
- type PluginDecl
- type RemotePlugin
Constants ¶
This section is empty.
Variables ¶
var SupportedFormats = map[Format]FormatFactory{ JSON: FormatFactory{50, jsonFactory}, XML: FormatFactory{0, xmlFactory}, }
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Muxer // contains filtered or unexported fields }
func NewClient ¶
func NewClient(decl PluginDecl, r io.ReadCloser, w io.WriteCloser) (c *Client, err error)
Creates a new plugin client from a declaration, a reader and the corresponding writer. The Format field of the declaration can be omitted (nil) and will in that case be set to a list of formats supported by the system (All keys in SupportedFormats).
type FormatFactory ¶
type FormatFactory struct { Weight int Construct func(r io.ReadCloser, w io.WriteCloser) (Encoder, Decoder) }
type HandlerFunc ¶
func (HandlerFunc) HandleEvent ¶
func (hf HandlerFunc) HandleEvent(event Event, args Args)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A plugin manager Manages plugins by routing events between them. Also allows a local handler to recieve the events and react to them.
func NewManager ¶
func NewManager() *Manager
Returns a new plugin Manager ready for use. A default Muxer is installed as the handler
func (Manager) Dispatch ¶
Introduces a new event into the handler for processing and sending to relevant plugins.
func (*Manager) Handle ¶
Registers a plugin to be handled by the handler. The name of the plugin must be unique
func (*Manager) HandleAll ¶
Convenience method Equivalent to calling Handle on all plugins individually
func (*Manager) ListenAndServe ¶
type Plugin ¶
type Plugin interface { Name() string Provides() []Event Subscribes() []Event Send(Event, Args) error Recieve() (Event, Args, error) }
type PluginDecl ¶
type RemotePlugin ¶
type RemotePlugin struct { PluginDecl // contains filtered or unexported fields }
func NewRemotePlugin ¶
func NewRemotePlugin(r io.ReadCloser, w io.WriteCloser) (pl *RemotePlugin, err error)
func (RemotePlugin) Name ¶
func (rp RemotePlugin) Name() string
func (RemotePlugin) Provides ¶
func (rp RemotePlugin) Provides() []Event
func (RemotePlugin) Subscribes ¶
func (rp RemotePlugin) Subscribes() []Event