bees

package
v0.0.0-...-42619b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2017 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Package bees is Beehive's central module system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertValue

func ConvertValue(v interface{}, dst interface{}) error

ConvertValue tries to convert v to dst.

func DeleteBee

func DeleteBee(bee *BeeInterface)

DeleteBee removes a Bee instance.

func Log

func Log(bee string, message string, messageType uint)

Log adds a new LogMessage to the log

func RegisterBee

func RegisterBee(bee BeeInterface)

RegisterBee gets called by Bees to register themselves.

func RegisterFactory

func RegisterFactory(factory BeeFactoryInterface)

RegisterFactory gets called by BeeFactories to register themselves.

func RestartBee

func RestartBee(bee *BeeInterface)

RestartBee restarts a Bee.

func RestartBees

func RestartBees(bees []BeeConfig)

RestartBees stops all running bees and restarts a new set of bees.

func SetActions

func SetActions(as []Action)

SetActions sets the currently configured actions.

func SetChains

func SetChains(cs []Chain)

SetChains sets the currently configured chains

func StartBees

func StartBees(beeList []BeeConfig)

StartBees starts all registered bees.

func StopBees

func StopBees()

StopBees stops all bees gracefully.

func UUID

func UUID() string

UUID generates a new unique ID.

Types

type Action

type Action struct {
	ID      string
	Bee     string
	Name    string
	Options Placeholders
}

Action describes an action.

func GetAction

func GetAction(id string) *Action

GetAction returns one action with a specific ID.

func GetActions

func GetActions() []Action

GetActions returns all configured actions.

type ActionDescriptor

type ActionDescriptor struct {
	Namespace   string
	Name        string
	Description string
	Options     []PlaceholderDescriptor
}

ActionDescriptor describes an Action provided by a Bee.

func GetActionDescriptor

func GetActionDescriptor(action *Action) ActionDescriptor

GetActionDescriptor returns the ActionDescriptor matching an action.

type Bee

type Bee struct {
	Running bool
	SigChan chan bool
	// contains filtered or unexported fields
}

Bee is the base-struct to be embedded by bee implementations.

func NewBee

func NewBee(name, factoryName, description string, options []BeeOption) Bee

NewBee returns a new bee and sets up sig-channel & waitGroup.

func (*Bee) Action

func (bee *Bee) Action(action Action) []Placeholder

Action is the default, empty implementation of a Bee's Action method.

func (*Bee) Config

func (bee *Bee) Config() BeeConfig

Config returns the config for a bee.

func (*Bee) Description

func (bee *Bee) Description() string

Description returns the description for a bee.

func (*Bee) IsRunning

func (bee *Bee) IsRunning() bool

IsRunning returns whether a Bee is currently running.

func (*Bee) LastAction

func (bee *Bee) LastAction() time.Time

LastAction returns the timestamp of the last triggered action.

func (*Bee) LastEvent

func (bee *Bee) LastEvent() time.Time

LastEvent returns the timestamp of the last triggered event.

func (*Bee) LogAction

func (bee *Bee) LogAction()

LogAction logs the last triggered action.

func (*Bee) LogErrorf

func (bee *Bee) LogErrorf(format string, args ...interface{})

LogErrorf logs a formatted error string

func (*Bee) LogEvent

func (bee *Bee) LogEvent()

LogEvent logs the last triggered event.

func (*Bee) LogFatal

func (bee *Bee) LogFatal(args ...interface{})

LogFatal logs a fatal error

func (*Bee) Logf

func (bee *Bee) Logf(format string, args ...interface{})

Logf logs a formatted string

func (*Bee) Logln

func (bee *Bee) Logln(args ...interface{})

Logln logs args

func (*Bee) Name

func (bee *Bee) Name() string

Name returns the configured name for a bee.

func (*Bee) Namespace

func (bee *Bee) Namespace() string

Namespace returns the namespace for a bee.

func (*Bee) Options

func (bee *Bee) Options() BeeOptions

Options returns the options for a bee.

func (*Bee) Run

func (bee *Bee) Run(chan Event)

Run is the default, empty implementation of a Bee's Run method.

func (*Bee) SetDescription

func (bee *Bee) SetDescription(s string)

SetDescription sets the description for a bee.

func (*Bee) SetOptions

func (bee *Bee) SetOptions(options BeeOptions)

SetOptions sets the options for a bee.

func (*Bee) SetSigChan

func (bee *Bee) SetSigChan(c chan bool)

SetSigChan sets the signaling channel for a bee.

func (*Bee) Start

func (bee *Bee) Start()

Start gets called when a Bee gets started.

func (*Bee) Stop

func (bee *Bee) Stop()

Stop gracefully stops a Bee.

func (*Bee) WaitGroup

func (bee *Bee) WaitGroup() *sync.WaitGroup

WaitGroup returns the WaitGroup for a bee.

type BeeConfig

type BeeConfig struct {
	Name        string
	Class       string
	Description string
	Options     BeeOptions
}

BeeConfig contains all settings for a single Bee.

func BeeConfigs

func BeeConfigs() []BeeConfig

BeeConfigs returns configs for all Bees.

func NewBeeConfig

func NewBeeConfig(name, class, description string, options BeeOptions) (BeeConfig, error)

NewBeeConfig validates a configuration and sets up a new BeeConfig

type BeeFactory

type BeeFactory struct {
}

A BeeFactory is the base struct to be embedded by other BeeFactories.

func (*BeeFactory) Actions

func (factory *BeeFactory) Actions() []ActionDescriptor

Actions returns the default empty actions set.

func (*BeeFactory) Events

func (factory *BeeFactory) Events() []EventDescriptor

Events returns the default empty events set.

func (*BeeFactory) Image

func (factory *BeeFactory) Image() string

Image returns an empty image filename per default.

func (*BeeFactory) LogoColor

func (factory *BeeFactory) LogoColor() string

LogoColor returns the default logo color.

func (*BeeFactory) OAuth2AccessToken

func (factory *BeeFactory) OAuth2AccessToken(id, secret, code string) (*oauth2.Token, error)

OAuth2AccessToken returns the oauth2 access token.

func (*BeeFactory) Options

func (factory *BeeFactory) Options() []BeeOptionDescriptor

Options returns the default empty options set.

type BeeFactoryInterface

type BeeFactoryInterface interface {
	// ID of the module
	ID() string
	// Name of the module
	Name() string
	// Description of the module
	Description() string
	// An image url for the module
	Image() string
	// A logo color for the module
	LogoColor() string

	// OAuth2AccessToken returns the oauth2 access token.
	OAuth2AccessToken(id, secret, code string) (*oauth2.Token, error)

	// Options supported by module
	Options() []BeeOptionDescriptor
	// Events defined by module
	Events() []EventDescriptor
	// Actions supported by module
	Actions() []ActionDescriptor

	New(name, description string, options BeeOptions) BeeInterface
}

A BeeFactoryInterface is the interface that gets implemented by a BeeFactory.

func GetFactories

func GetFactories() []*BeeFactoryInterface

GetFactories returns all known bee factories.

func GetFactory

func GetFactory(identifier string) *BeeFactoryInterface

GetFactory returns the factory with a specific name.

type BeeInterface

type BeeInterface interface {
	// Name of the bee
	Name() string
	// Namespace of the bee
	Namespace() string

	// Description of the bee
	Description() string
	// SetDescription sets a description
	SetDescription(s string)

	// Config returns this bees config
	Config() BeeConfig
	// Options of the bee
	Options() BeeOptions
	// SetOptions to configure the bee
	SetOptions(options BeeOptions)

	// ReloadOptions gets called after a bee's options get updated
	ReloadOptions(options BeeOptions)

	// Activates the bee
	Run(eventChannel chan Event)
	// Running returns the current state of the bee
	IsRunning() bool
	// Start the bee
	Start()
	// Stop the bee
	Stop()

	LastEvent() time.Time
	LogEvent()
	LastAction() time.Time
	LogAction()

	Logln(args ...interface{})
	Logf(format string, args ...interface{})
	LogErrorf(format string, args ...interface{})
	LogFatal(args ...interface{})

	SetSigChan(c chan bool)
	WaitGroup() *sync.WaitGroup

	// Handles an action
	Action(action Action) []Placeholder
}

BeeInterface is an interface all bees implement.

func GetBee

func GetBee(identifier string) *BeeInterface

GetBee returns a bee with a specific name.

func GetBees

func GetBees() []*BeeInterface

GetBees returns all known bees.

func NewBeeInstance

func NewBeeInstance(bee BeeConfig) *BeeInterface

NewBeeInstance sets up a new Bee with supplied config.

func StartBee

func StartBee(bee BeeConfig) *BeeInterface

StartBee starts a bee.

type BeeOption

type BeeOption struct {
	Name  string
	Value interface{}
}

A BeeOption is used to configure bees.

type BeeOptionDescriptor

type BeeOptionDescriptor struct {
	Name        string
	Description string
	Type        string
	Default     interface{}
	Mandatory   bool
}

A BeeOptionDescriptor shows which config values a module expects.

type BeeOptions

type BeeOptions []BeeOption

BeeOptions is an array of BeeOption.

func (BeeOptions) Bind

func (opts BeeOptions) Bind(name string, dst interface{}) error

Bind a value from a BeeOptions slice.

func (BeeOptions) Value

func (opts BeeOptions) Value(name string) interface{}

Value retrieves a value from a BeeOptions slice.

type Chain

type Chain struct {
	Name        string
	Description string
	Event       *Event
	Filters     []string
	Actions     []string
	Elements    []ChainElement `json:"Elements,omitempty"`
}

Chain is a user defined chain

func GetChain

func GetChain(id string) *Chain

GetChain returns a chain with a specific id

func GetChains

func GetChains() []Chain

GetChains returns all chains

type ChainElement

type ChainElement struct {
	Action Action
	Filter Filter
}

ChainElement is an element in a Chain

type Event

type Event struct {
	Bee     string
	Name    string
	Options Placeholders
}

An Event describes an event including its parameters.

type EventDescriptor

type EventDescriptor struct {
	Namespace   string
	Name        string
	Description string
	Options     []PlaceholderDescriptor
}

EventDescriptor describes an Event provided by a Bee.

func GetEventDescriptor

func GetEventDescriptor(event *Event) EventDescriptor

GetEventDescriptor returns the EventDescriptor matching an event.

type Filter

type Filter struct {
	ID      string
	Name    string
	Options FilterOption
}

Filter describes a user configured event filter.

type FilterOption

type FilterOption struct {
	Name            string
	Type            string
	Inverse         bool
	CaseInsensitive bool
	Trimmed         bool
	Value           interface{}
}

A FilterOption used by filters.

type LogMessage

type LogMessage struct {
	ID          string
	Bee         string
	Message     string
	MessageType uint
	Timestamp   time.Time
}

LogMessage stores a log message with its timestamp, type and originating Bee

func GetLogs

func GetLogs(bee string) []LogMessage

GetLogs returns all logs for a Bee.

func NewLogMessage

func NewLogMessage(bee string, message string, messageType uint) LogMessage

NewLogMessage returns a newly composed LogMessage

type LogSorter

type LogSorter []LogMessage

LogSorter is used for sorting an array of LogMessages by their timestamp

func (LogSorter) Len

func (a LogSorter) Len() int

func (LogSorter) Less

func (a LogSorter) Less(i, j int) bool

func (LogSorter) Swap

func (a LogSorter) Swap(i, j int)

type Placeholder

type Placeholder struct {
	Name  string
	Type  string
	Value interface{}
}

Placeholder used by ins & outs of a bee.

type PlaceholderDescriptor

type PlaceholderDescriptor struct {
	Name        string
	Description string
	Type        string
	Mandatory   bool
}

A PlaceholderDescriptor shows which in & out values a module expects and returns.

type Placeholders

type Placeholders []Placeholder

Placeholders is an array of Placeholder.

func (Placeholders) Bind

func (ph Placeholders) Bind(name string, dst interface{}) error

Bind a value from a Placeholder slice.

func (*Placeholders) SetValue

func (ph *Placeholders) SetValue(name string, _type string, value interface{})

SetValue sets a value in the Placeholder slice.

func (Placeholders) Value

func (ph Placeholders) Value(name string) interface{}

Value retrieves a value from a Placeholder slice.

Directories

Path Synopsis
Package alertoverbee is able to send notifications on AlertOver.
Package alertoverbee is able to send notifications on AlertOver.
Package anelpowerctrlbee is a Bee for talking to Anel's PowerCtrl network power sockets.
Package anelpowerctrlbee is a Bee for talking to Anel's PowerCtrl network power sockets.
Package cleverbotbee is a Bee that can interact with cleverbot
Package cleverbotbee is a Bee that can interact with cleverbot
Package cronbee is a Bee that acts like a time-based job scheduler (cron).
Package cronbee is a Bee that acts like a time-based job scheduler (cron).
cron
Package cron allows you to schedule events.
Package cron allows you to schedule events.
Package devrantbee is a Bee that can post blogs & quotes on Devrant.
Package devrantbee is a Bee that can post blogs & quotes on Devrant.
Package efabee is a Bee that interfaces with the public EVA API.
Package efabee is a Bee that interfaces with the public EVA API.
Package emailbee is a Bee that is able to send emails.
Package emailbee is a Bee that is able to send emails.
Package execbee is a Bee that can launch external processes.
Package execbee is a Bee that can launch external processes.
Package facebookbee is a Bee that can interface with Facebook.
Package facebookbee is a Bee that can interface with Facebook.
Package githubbee is a Bee that can interface with GitHub Package githubbee is a Bee that can interface with GitHub Package githubbee is a Bee that can interface with GitHub
Package githubbee is a Bee that can interface with GitHub Package githubbee is a Bee that can interface with GitHub Package githubbee is a Bee that can interface with GitHub
Package gitterbee is a Bee that can interface with Gitter Package gitterbee is a Bee that can interface with Gitter
Package gitterbee is a Bee that can interface with Gitter Package gitterbee is a Bee that can interface with Gitter
Package hellobee is an example for a Bee skeleton, designed to help you get started with writing your own Bees.
Package hellobee is an example for a Bee skeleton, designed to help you get started with writing your own Bees.
Package htmlextractbee is a Bee that can extract metadata from HTTP URLs.
Package htmlextractbee is a Bee that can extract metadata from HTTP URLs.
Package httpbee is a Bee that lets you trigger HTTP requests.
Package httpbee is a Bee that lets you trigger HTTP requests.
Package huebee is a Bee that can talk to Philips Hue bridges.
Package huebee is a Bee that can talk to Philips Hue bridges.
Package ircbee is a Bee that can connect to an IRC server.
Package ircbee is a Bee that can connect to an IRC server.
irctools
Package irctools is a collection of convenient IRC styling methods.
Package irctools is a collection of convenient IRC styling methods.
Package jabberbee is a Bee that can connect to a Jabber/XMPP server.
Package jabberbee is a Bee that can connect to a Jabber/XMPP server.
Package jenkinsbee is a Bee that can interface with a Jenkins server.
Package jenkinsbee is a Bee that can interface with a Jenkins server.
Package mumblebee is a Bee that can connect to a Mumble/XMPP server.
Package mumblebee is a Bee that can connect to a Mumble/XMPP server.
Package nagiosbee is a Bee that can interface with a Nagios instance.
Package nagiosbee is a Bee that can interface with a Nagios instance.
Package notificationbee is a Bee that can trigger desktop notifications.
Package notificationbee is a Bee that can trigger desktop notifications.
Package pastebinbee is a Bee that can interface with Pastebin.
Package pastebinbee is a Bee that can interface with Pastebin.
Package pushoverbee is a Bee that can send pushover notifications.
Package pushoverbee is a Bee that can send pushover notifications.
Package rssbee is a Bee for handling RSS feeds.
Package rssbee is a Bee for handling RSS feeds.
Package serialbee is a Bee that can send & receive data on a serial port.
Package serialbee is a Bee that can send & receive data on a serial port.
Package simplepushbee is a Bee that is able to send push notifications to Android.
Package simplepushbee is a Bee that is able to send push notifications to Android.
Package slackbee is a Bee that can connect to Slack.
Package slackbee is a Bee that can connect to Slack.
Package spaceapibee is a Bee that can query a spaceapi server.
Package spaceapibee is a Bee that can query a spaceapi server.
Package telegrambee is a Bee that can connect to Telegram.
Package telegrambee is a Bee that can connect to Telegram.
Package timebee is a Bee that can fire events at a specific time.
Package timebee is a Bee that can fire events at a specific time.
Package tinderbee is a Bee that can post blogs & quotes on Tinder.
Package tinderbee is a Bee that can post blogs & quotes on Tinder.
Package transmissionbee is a Bee that can send torrents to Transmission.
Package transmissionbee is a Bee that can send torrents to Transmission.
Package tumblrbee is a Bee that can post blogs & quotes on Tumblr.
Package tumblrbee is a Bee that can post blogs & quotes on Tumblr.
Package twiliobee is a Bee that is able to send SMS messages.
Package twiliobee is a Bee that is able to send SMS messages.
Package twitterbee is a Bee that can interface with Twitter.
Package twitterbee is a Bee that can interface with Twitter.
Package webbee is a Bee that starts an HTTP server and fires events for incoming requests.
Package webbee is a Bee that starts an HTTP server and fires events for incoming requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL