Documentation ¶
Overview ¶
Package nats contains utilties for reading/writing data using NATS.
Index ¶
- func DecodeEdgePointsMsg(msg *natsgo.Msg) (string, string, []data.Point, error)
- func DecodeNodePointsMsg(msg *natsgo.Msg) (string, []data.Point, error)
- func DeleteNode(nc *natsgo.Conn, id, parent string) error
- func Dump(nc *natsgo.Conn, msg *natsgo.Msg) error
- func DuplicateNode(nc *natsgo.Conn, id, newParent string) error
- func EdgeConnect(eo EdgeOptions) (*nats.Conn, error)
- func ExpBackoff(attempts int, max time.Duration) time.Duration
- func GetNode(nc *natsgo.Conn, id, parent string) ([]data.NodeEdge, error)
- func GetNodeChildren(nc *natsgo.Conn, id, typ string, includeDel bool, recursive bool) ([]data.NodeEdge, error)
- func GetNodesForUser(nc *natsgo.Conn, userID string) ([]data.NodeEdge, error)
- func ListenForFile(nc *nats.Conn, dir, deviceID string, callback func(path string)) error
- func MirrorNode(nc *natsgo.Conn, id, newParent string) error
- func MoveNode(nc *natsgo.Conn, id, oldParent, newParent string) error
- func SendEdgePoint(nc *natsgo.Conn, nodeID, parentID string, point data.Point, ack bool) error
- func SendEdgePoints(nc *natsgo.Conn, nodeID, parentID string, points data.Points, ack bool) error
- func SendFile(nc *nats.Conn, deviceID string, reader io.Reader, name string, ...) error
- func SendNode(nc *natsgo.Conn, node data.NodeEdge) error
- func SendNodePoint(nc *natsgo.Conn, nodeID string, point data.Point, ack bool) error
- func SendNodePointCreate(nc *natsgo.Conn, nodeID string, point data.Point, ack bool) error
- func SendNodePoints(nc *natsgo.Conn, nodeID string, points data.Points, ack bool) error
- func SendNodePointsCreate(nc *natsgo.Conn, nodeID string, points data.Points, ack bool) error
- func String(nc *natsgo.Conn, msg *natsgo.Msg) (string, error)
- func SubjectEdgeAllPoints() string
- func SubjectEdgePoints(nodeID, parentID string) string
- func SubjectNodeAllPoints() string
- func SubjectNodePoints(nodeID string) string
- func UserCheck(nc *natsgo.Conn, email, pass string) ([]data.NodeEdge, error)
- type EdgeOptions
- type Metric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeEdgePointsMsg ¶ added in v0.0.30
DecodeEdgePointsMsg decodes NATS message into node ID and points
func DecodeNodePointsMsg ¶ added in v0.0.23
DecodeNodePointsMsg decodes NATS message into node ID and points
func DeleteNode ¶ added in v0.0.45
DeleteNode removes a node from the specified parent node
func DuplicateNode ¶ added in v0.0.44
DuplicateNode is used to Duplicate a node and all its children
func EdgeConnect ¶
func EdgeConnect(eo EdgeOptions) (*nats.Conn, error)
EdgeConnect is a function that attempts connections for edge devices with appropriate timeouts, backups, etc. Currently set to disconnect if we don't have a connection after 6m, and then exp backup to try to connect every 6m after that.
func ExpBackoff ¶
ExpBackoff calculates an exponential time backup to max duration + a random fraction of 1s
func GetNode ¶ added in v0.0.30
GetNode over NATS. If id is "root", the root node is fetched. If parent is set to "none", the edge details are not included and the hash is calculated without the edge points. returns data.ErrDocumentNotFound if node is not found. If parent is set to "all", then all living instances of the node are returned.
func GetNodeChildren ¶ added in v0.0.30
func GetNodeChildren(nc *natsgo.Conn, id, typ string, includeDel bool, recursive bool) ([]data.NodeEdge, error)
GetNodeChildren over NATS (immediate children only, not recursive) deleted nodes are skipped unless includeDel is set to true. typ can be used to limit nodes to a particular type, otherwise, all nodes are returned.
func GetNodesForUser ¶ added in v0.0.42
GetNodesForUser gets all nodes for a user
func ListenForFile ¶
ListenForFile listens for a file sent from server. dir is the directly to place downloaded files.
func MirrorNode ¶ added in v0.0.45
MirrorNode adds a an existing node to a new parent. A node can have multiple parents.
func SendEdgePoint ¶ added in v0.0.30
SendEdgePoint sends a edge point using the nats protocol
func SendEdgePoints ¶ added in v0.0.30
SendEdgePoints sends points using the nats protocol
func SendFile ¶
func SendFile(nc *nats.Conn, deviceID string, reader io.Reader, name string, callback func(int)) error
SendFile can be used to send a file to a device. Callback provides bytes transfered.
func SendNode ¶ added in v0.0.30
SendNode is used to send a node to a nats server. Can be used to create nodes.
func SendNodePoint ¶ added in v0.0.30
SendNodePoint sends a node point using the nats protocol
func SendNodePointCreate ¶ added in v0.0.30
SendNodePointCreate sends a node point using the nats protocol and creates the node if it does not already exist
func SendNodePoints ¶ added in v0.0.30
SendNodePoints sends node points using the nats protocol
func SendNodePointsCreate ¶ added in v0.0.30
SendNodePointsCreate sends a node point using the nats protocol and creates the node if it does not already exist
func SubjectEdgeAllPoints ¶ added in v0.0.30
func SubjectEdgeAllPoints() string
SubjectEdgeAllPoints provides subject for all edge points for any node
func SubjectEdgePoints ¶ added in v0.0.30
SubjectEdgePoints constructs a NATS subject for edge points
func SubjectNodeAllPoints ¶ added in v0.0.30
func SubjectNodeAllPoints() string
SubjectNodeAllPoints provides subject for all points for any node
func SubjectNodePoints ¶ added in v0.0.30
SubjectNodePoints constructs a NATS subject for node points
Types ¶
type EdgeOptions ¶
type EdgeOptions struct { URI string AuthToken string NoEcho bool Disconnected func() Reconnected func() Closed func() }
EdgeOptions describes options for connecting edge devices
type Metric ¶ added in v0.0.34
type Metric struct {
// contains filtered or unexported fields
}
Metric is a type that can be used to track metrics and periodically report them to a node point. Data is queued and averaged and then the average is sent out as a point.