Documentation
¶
Index ¶
- func DecodeNodeMsg(msg *natsgo.Msg) (string, []data.Point, error)
- func EdgeConnect(o EdgeOptions) (*nats.Conn, error)
- func ExpBackoff(attempts int, max time.Duration) time.Duration
- func ListenForCmd(nc *nats.Conn, deviceID string, callback func(cmd data.NodeCmd)) error
- func ListenForFile(nc *nats.Conn, dir, deviceID string, callback func(path string)) error
- func SendCmd(nc *nats.Conn, cmd data.NodeCmd, timeout time.Duration) error
- func SendFile(nc *nats.Conn, deviceID string, reader io.Reader, name string, ...) error
- func SendPoint(nc *natsgo.Conn, nodeID string, point data.Point, ack bool) error
- func SendPoints(nc *natsgo.Conn, nodeID string, points data.Points, ack bool) error
- type EdgeOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeNodeMsg ¶ added in v0.0.22
DecodeNodeMsg decodes NATS message into node ID and points
func EdgeConnect ¶
func EdgeConnect(o 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 ListenForCmd ¶
ListenForCmd listens for a file sent from server
func ListenForFile ¶
ListenForFile listens for a file sent from server. dir is the directly to place downloaded files.
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.
Types ¶
type EdgeOptions ¶
type EdgeOptions struct {
Server string
AuthToken string
Disconnected func()
Reconnected func()
Closed func()
}
EdgeOptions describes options for connecting edge devices