Documentation ¶
Overview ¶
Package node provides an interfaces to add, delete, get an target edge device.
Index ¶
- Constants
- type Command
- type Executor
- func (Executor) GetNode(nodeId string) (int, map[string]interface{}, error)
- func (Executor) GetNodeConfiguration(nodeId string) (int, map[string]interface{}, error)
- func (Executor) GetNodes() (int, map[string]interface{}, error)
- func (Executor) GetNodesWithAppID(appID string) (int, map[string]interface{}, error)
- func (executor Executor) PingNode(nodeId string, body string) (int, error)
- func (Executor) Reboot(nodeId string) (int, error)
- func (Executor) RegisterNode(body string) (int, map[string]interface{}, error)
- func (Executor) Restore(nodeId string) (int, error)
- func (Executor) SetNodeConfiguration(nodeId string, body string) (int, error)
- func (Executor) UnRegisterNode(nodeId string) (int, error)
- func (Executor) UpdateNodeStatus(nodeId string, status string) error
Constants ¶
const ( NODE = "node" // used to indicate a node. NODES = "nodes" // used to indicate a list of nodes. ID = "id" // used to indicate an node id. APPS = "apps" // used to indicate a list of apps. EVENT = "event" // used to indicate an event. EVENT_ID = "eventid" // used to indicate an event id. TIMESTAMP = "timestamp" // used to indicate the time at which the event was created. HOST = "host" // used to indicate an node address. PORT = "port" // used to indicate an node port. STATUS = "status" // used to update node status. STATUS_REGISTERED = "registered" // used to update node status with registered. STATUS_CONNECTED = "connected" // used to update node status with connected. STATUS_DISCONNECTED = "disconnected" // used to update node status with disconnected. INTERVAL = "interval" // a period between two healthcheck message. MAXIMUM_NETWORK_LATENCY_SEC = 3 // the term used to indicate any kind of delay that happens in data communication over a network. TIME_UNIT = time.Minute // the minute is a unit of time for healthcheck. PROPERTIES = "properties" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { RegisterNode(body string) (int, map[string]interface{}, error) UnRegisterNode(nodeId string) (int, error) GetNode(nodeId string) (int, map[string]interface{}, error) GetNodes() (int, map[string]interface{}, error) GetNodesWithAppID(appId string) (int, map[string]interface{}, error) UpdateNodeStatus(nodeId string, status string) error PingNode(nodeId string, body string) (int, error) GetNodeConfiguration(nodeId string) (int, map[string]interface{}, error) SetNodeConfiguration(nodeId string, body string) (int, error) Reboot(nodeId string) (int, error) Restore(nodeId string) (int, error) }
Command is an interface of node operations.
type Executor ¶
type Executor struct{}
Executor implements the Command interface.
func (Executor) GetNode ¶
GetNode returns the node with a primary key matching the nodeId argument. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.
func (Executor) GetNodeConfiguration ¶
func (Executor) GetNodes ¶
GetNodes returns all nodes in databases as an array. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.
func (Executor) GetNodesWithAppID ¶
func (Executor) PingNode ¶
PingNode starts timer with received interval. If node does not send next healthcheck message in interval time, change the status of device from connected to disconnected. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.
func (Executor) Reboot ¶
Reboot reboots the device with nodeId. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.
func (Executor) RegisterNode ¶
RegisterNode inserts a new node with ip which is passed in call to function. If successful, a unique id that is created automatically will be returned. otherwise, an appropriate error will be returned.
func (Executor) Restore ¶
Restore restore the device with nodeId to initial state. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.
func (Executor) SetNodeConfiguration ¶
func (Executor) UnRegisterNode ¶
UnRegisterNode deletes the node with a primary key matching the nodeId argument. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.