apitools

package
v4.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-2-Clause Imports: 15 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout             = errors.New("timed out")
	ErrEmptyBrokerAddress  = errors.New("broker address is empty")
	ErrMissingAPIToken     = errors.New("api token has not been set")
	ErrMissingCollectionID = errors.New("collection ID has not been set")
)

errors

Functions

func ContextWithAuth

func ContextWithAuth(token string) context.Context

ContextWithAuth returns a context with the API token set

func ContextWithAuthAndTimeout added in v4.1.14

func ContextWithAuthAndTimeout(token string, timeout time.Duration) (context.Context, func())

ContextWithAuthAndTimeout returns a context with the API token set and timeout

Types

type DataStream

type DataStream interface {
	Recv() (spanapi.OutputDataMessage, error)
	Close() error
}

DataStream is a stream of data from the Span service. The data stream uses a websocket under the hood.

func NewCollectionDataStream

func NewCollectionDataStream(ctx context.Context, config *spanapi.Configuration, collectionID string) (DataStream, error)

NewCollectionDataStream creates a live data stream for devices in a collection. The context must contain the appropriate credentials.

func NewDeviceDataStream

func NewDeviceDataStream(ctx context.Context, config *spanapi.Configuration, collectionID, deviceID string) (DataStream, error)

NewDeviceDataStream creates a live data stream for a single device. The context must contain the appropriate credentials.

func NewMQTTStream added in v4.2.3

func NewMQTTStream(options ...MQTTOption) (DataStream, error)

NewMQTTStream creates a new data stream that uses the Span MQTT broker

type MQTTOption added in v4.2.3

type MQTTOption func(opt *mqttParam) *mqttParam

MQTTOption is an option type for MQTT streams

func WithAPIToken added in v4.2.3

func WithAPIToken(token string) MQTTOption

WithAPIToken sets the API token to use when streaming data

func WithBrokerOverride added in v4.2.3

func WithBrokerOverride(broker string) MQTTOption

WithBrokerOverride overrides the default MQTT broker endpoint.

func WithClientID added in v4.2.3

func WithClientID(id string) MQTTOption

WithClientID sets the client ID to use.

func WithCollectionID added in v4.2.3

func WithCollectionID(collectionID string) MQTTOption

WithCollectionID sets the collection ID to use when streaming data

Jump to

Keyboard shortcuts

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