Documentation
¶
Index ¶
- func CmpRemote(this, other interface{}) int
- func KillBot(ctx actor.Context, pid *actor.PID)
- type BasicBot
- type Bot
- func (state *Bot) ActivePlugins() []*plgn.PluginIdentifier
- func (state *Bot) AddActivePlugin(plugin *plgn.PluginIdentifier)
- func (state *Bot) AddPeer(pid ...*actor.PID)
- func (state *Bot) AddRemote(host ...*Remote)
- func (state *Bot) AddSubscriber(subscriber *actor.PID, messageTypes ...msg.MessageType)
- func (state *Bot) NotifySubscribers(ctx actor.Context, message interface{})
- func (state *Bot) Peers(pid *actor.PID) *actor.PIDSet
- func (state *Bot) PluginLogger() *log.Logger
- func (state *Bot) Receive(ctx actor.Context)
- func (state *Bot) RemoteRepoUrl() *url.URL
- func (state *Bot) Remotes() []*Remote
- func (state *Bot) RemoveActivePlugin(plugin plgn.Plugin)
- func (state *Bot) RemovePeer(pid ...*actor.PID)
- func (state *Bot) RemoveRemote(host ...*Remote)
- func (state *Bot) RemoveSubscriber(unsubscriber *actor.PID, messageTypes ...msg.MessageType)
- func (state *Bot) SetPeers(peers *actor.PIDSet)
- func (state *Bot) SetRemoteRepoUrl(url *url.URL)
- func (state *Bot) SetRemotes(remotes sets.Set)
- func (state *Bot) SpawnBot(ctx actor.Context, host string, port int) (*actor.PID, error)
- func (state *Bot) Subscribers() map[msg.MessageType]*actor.PIDSet
- type FinishedFunc
- type LifetimeObservable
- type Pluggable
- type PluggableRepository
- type PluginContract
- type Remotable
- type Remote
- type Subscribable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BasicBot ¶
type BasicBot interface {
// a bot that is capable of spawning remote actors
Remotable
// ability to plug in functionality
Pluggable
// ability to subscribe/ unsubscribe to messages
Subscribable
// a bot must have an repository from which to download plugins
PluggableRepository
// a bot is an actor so it must have a Receive method
Receive(ctx actor.Context)
// a bot's lifecycle should be observable
LifetimeObservable
}
Basic bot
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
func (*Bot) ActivePlugins ¶
func (state *Bot) ActivePlugins() []*plgn.PluginIdentifier
Get active plugins
func (*Bot) AddActivePlugin ¶
func (state *Bot) AddActivePlugin(plugin *plgn.PluginIdentifier)
Add a plugin to active plugins
func (*Bot) AddSubscriber ¶
func (state *Bot) AddSubscriber(subscriber *actor.PID, messageTypes ...msg.MessageType)
Adds a new subscriber to for a certain messaget type If no message type is specified, a subscription for all messages is created
func (*Bot) NotifySubscribers ¶
Notify relevant subscribers that an event they have subscribed to has occurred.
func (*Bot) PluginLogger ¶
Get logger for use in plugins
func (*Bot) Receive ¶
Proto.Actor central Receive() method which gets passed all messages sent to the post box of this actor.
func (*Bot) RemoveActivePlugin ¶
Remove a plugin from active plugins.
func (*Bot) RemoveSubscriber ¶
func (state *Bot) RemoveSubscriber(unsubscriber *actor.PID, messageTypes ...msg.MessageType)
Removes a new subscriber from a certain message type If no message type is specified, all subscriptions are removed
func (*Bot) SetRemoteRepoUrl ¶
Set URL to remote repository
func (*Bot) Subscribers ¶
func (state *Bot) Subscribers() map[msg.MessageType]*actor.PIDSet
Get subscribers
type FinishedFunc ¶
type FinishedFunc func()
type LifetimeObservable ¶
type LifetimeObservable interface {
// contains filtered or unexported methods
}
Handler methods for lifecycle event
type Pluggable ¶
type Pluggable interface {
// Get logger for plugins
PluginLogger() *log.Logger
// Get active plugins
ActivePlugins() []*plgn.PluginIdentifier
// Add a plugin to active plugins
AddActivePlugin(plugin *plgn.PluginIdentifier)
// Remove a plugin from active plugins
RemoveActivePlugin(plugin *plgn.PluginIdentifier)
// contains filtered or unexported methods
}
Ability to load plugins at runtime
type PluggableRepository ¶
type PluggableRepository interface {
// remote repository url
RemoteRepoUrl() string
// getter and setter
SetRemoteRepoUrl(url string)
}
Central, pluggable repository to obtain plugins from
type PluginContract ¶
type PluginContract struct {
OnActivated func(bot *Bot, ctx actor.Context, plugin plgn.Plugin)
OnDeactivated func(bot *Bot, ctx actor.Context, plugin plgn.Plugin)
Receive func(bot *Bot, ctx actor.Context, plugin plgn.Plugin, finished FinishedFunc)
}
Specification/ Contract which a plugin must obey to
type Remotable ¶
type Remotable interface {
// Get remotes
Remotes() sets.Set
// Set remotes
SetRemotes(remotes sets.Set)
// Get peers
// Adds a remote location
AddRemote(host ...string)
// Remove a remote location
RemoveRemote(host ...string)
// Get peers
Peers(pid *actor.PID) *actor.PIDSet
// Set peers
SetPeers(peers *actor.PIDSet)
// Add peer
AddPeer(pid ...*actor.PID)
// Remove peer
RemovePeer(pid ...*actor.PID)
// Spawn a bot on a given node
SpawnBot(ctx actor.Context, host string, port int) (*actor.PID, error)
// Kill a bot
KillBot(ctx actor.Context, pid *actor.PID)
// contains filtered or unexported methods
}
Holds remote locations (bot nodes) to spawn bots at
type Subscribable ¶
type Subscribable interface {
// Get subscribers
Subscribers() map[msg.MessageType]*actor.PIDSet
// Adds a new subscriber to for a certain messaget type
// If no message type is specified, a subscription for all messages is created
AddSubscriber(subscriber *actor.PID, messageTypes ...msg.MessageType)
// Handle *msg.Unsubscribe message
RemoveSubscriber(unsubscriber *actor.PID, messageTypes ...msg.MessageType)
// Notify subscribers about an event
NotifySubscribers(ctx actor.Context, message interface{})
// contains filtered or unexported methods
}
Ability to subsribe/ unsubsribe to events