node

package
v0.0.0-...-b0339d0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package node provides an interfaces to add, delete, get an target edge device.

Index

Constants

View Source
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

func (Executor) GetNode(nodeId string) (int, map[string]interface{}, error)

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) GetNodeConfiguration(nodeId string) (int, map[string]interface{}, error)

func (Executor) GetNodes

func (Executor) GetNodes() (int, map[string]interface{}, error)

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) GetNodesWithAppID(appID string) (int, map[string]interface{}, error)

func (Executor) PingNode

func (executor Executor) PingNode(nodeId string, body string) (int, error)

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

func (Executor) Reboot(nodeId string) (int, error)

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

func (Executor) RegisterNode(body string) (int, map[string]interface{}, error)

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

func (Executor) Restore(nodeId string) (int, error)

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) SetNodeConfiguration(nodeId string, body string) (int, error)

func (Executor) UnRegisterNode

func (Executor) UnRegisterNode(nodeId string) (int, error)

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.

func (Executor) UpdateNodeStatus

func (Executor) UpdateNodeStatus(nodeId string, status string) error

UpdateNodeStatus returns the node's status. If successful, this function returns an error as nil. otherwise, an appropriate error will be returned.

Directories

Path Synopsis
Package mock_node is a generated GoMock package.
Package mock_node is a generated GoMock package.

Jump to

Keyboard shortcuts

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