Documentation ¶
Index ¶
- Constants
- func NewNodeRouter(logger *log.Entry) *gin.Engine
- type Action
- type ActionCondition
- type ConnexionDetails
- type Event
- type EventHandler
- type EventNetwork
- type Node
- func (n *Node) BroadcastEvent(eventName, payload string)
- func (n *Node) ExecuteAction(action *Action, event *Event)
- func (n *Node) OnEventDo(eventName string, action *Action)
- func (n *Node) Register()
- func (n *Node) RegisterUI(endpoint string)
- func (n *Node) RetrieveLocalIp() net.IP
- func (n *Node) SendEventTo(receiver string, eventName, payload string)
- func (n *Node) ServeState(state interface{}, allowEdit bool)
- func (n *Node) ServeStatus()
- func (n *Node) SetEntryPoint(action *Action)
- func (n *Node) Start()
- func (n *Node) StartAPIServer()
- func (n *Node) WaitForExit()
- type NodeCapabilities
- type NodeConfig
- type NodeError
- type NodeInfo
- type NodeStatus
- type RabbitMQEventNetwork
- func (r *RabbitMQEventNetwork) BroadcastEvent(event *Event)
- func (r *RabbitMQEventNetwork) SendEventTo(receiver string, event *Event)
- func (r *RabbitMQEventNetwork) SetLogger(logger *log.Entry)
- func (r *RabbitMQEventNetwork) SetReceivedEventCallback(handler EventHandler)
- func (r *RabbitMQEventNetwork) StartListeningForEvents()
- type RegistrationServer
Constants ¶
View Source
const APIAddr = ":8081"
View Source
const EventsExchange = "events"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct { Name string Do EventHandler DoCondition ActionCondition DoDelay int Then *Action }
type ActionCondition ¶
type ConnexionDetails ¶
type EventHandler ¶
type EventHandler func(event *Event)
type EventNetwork ¶
type Node ¶
type Node struct { Info NodeInfo Config NodeConfig State internalState Logger *log.Entry RegistrationServer *RegistrationServer EventNetwork EventNetwork Router *gin.Engine Hardware hardware.Hal MediaController media.MediaController // contains filtered or unexported fields }
Node is the main component of the demokit. It aims to be a base for your own node and to provide an easy access to events happening in the network.
func NewDefaultNode ¶
func NewDefaultNode() *Node
NewDefaultNode returns a Node with a default configuration. The only components available are the Logger (logrus.Entry), the EventNetwork and the router (gin.Engine).
func NewNode ¶
func NewNode(info NodeInfo, config NodeConfig, logger *log.Entry, rs *RegistrationServer, network EventNetwork, mediaController media.MediaController, hal hardware.Hal) *Node
func (*Node) BroadcastEvent ¶
func (*Node) ExecuteAction ¶
func (*Node) OnEventDo ¶
OnEventDo is used to register an action to execute when a given event is received.
func (*Node) RegisterUI ¶
func (*Node) RetrieveLocalIp ¶
func (*Node) SendEventTo ¶
func (*Node) ServeState ¶
func (*Node) ServeStatus ¶
func (n *Node) ServeStatus()
func (*Node) SetEntryPoint ¶
func (*Node) StartAPIServer ¶
func (n *Node) StartAPIServer()
func (*Node) WaitForExit ¶
func (n *Node) WaitForExit()
type NodeCapabilities ¶
type NodeConfig ¶
type NodeConfig struct {
ExposeActions bool
}
func DefaultNodeConfig ¶
func DefaultNodeConfig() NodeConfig
type NodeStatus ¶
type NodeStatus struct { IsReady bool `json:"is_ready"` Capabilities NodeCapabilities `json:"capabilities"` RegisteredActions map[string][]string `json:"registered_actions"` RegisteredUIs []string `json:"registered_ui"` }
type RabbitMQEventNetwork ¶
type RabbitMQEventNetwork struct {
// contains filtered or unexported fields
}
func NewRabbitMQEventNetwork ¶
func NewRabbitMQEventNetwork(connDetails ConnexionDetails) *RabbitMQEventNetwork
func (*RabbitMQEventNetwork) BroadcastEvent ¶
func (r *RabbitMQEventNetwork) BroadcastEvent(event *Event)
func (*RabbitMQEventNetwork) SendEventTo ¶
func (r *RabbitMQEventNetwork) SendEventTo(receiver string, event *Event)
func (*RabbitMQEventNetwork) SetLogger ¶
func (r *RabbitMQEventNetwork) SetLogger(logger *log.Entry)
func (*RabbitMQEventNetwork) SetReceivedEventCallback ¶
func (r *RabbitMQEventNetwork) SetReceivedEventCallback(handler EventHandler)
func (*RabbitMQEventNetwork) StartListeningForEvents ¶
func (r *RabbitMQEventNetwork) StartListeningForEvents()
type RegistrationServer ¶
type RegistrationServer struct {
Addr string
}
func NewDefaultRegistrationServer ¶
func NewDefaultRegistrationServer(addr string) *RegistrationServer
func (*RegistrationServer) RegisterNode ¶
func (rs *RegistrationServer) RegisterNode(node *Node) error
Click to show internal directories.
Click to hide internal directories.