ingest

package
v0.0.0-...-36644ff Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ingest helps to send measurement data to edgeimpulse for processing into a model.

Index

Constants

This section is empty.

Variables

View Source
var IngestionBaseURL = "https://ingestion.edgeimpulse.com"

IngestionBaseURL is the default URL for uploading data.

Functions

This section is empty.

Types

type CollectPayload

type CollectPayload struct {
	DeviceName string      `json:"device_name,omitempty"` // Optional.
	DeviceType string      `json:"device_type"`
	IntervalMS int64       `json:"interval_ms"`
	Sensors    []Sensor    `json:"sensors"` // All sensors in this payload.
	Values     [][]float64 `json:"values"`  // Values for each sensor. Each slice in Values must correspond to Sensors.
}

CollectPayload is data to upload to EdgeImpulse for processing.

func (*CollectPayload) AddData

func (p *CollectPayload) AddData(data []float64) error

AddData adds one set of measurements. One value for each sensor.

type Collector

type Collector struct {
	HTTPClient       *http.Client
	IngestionBaseURL string
	// contains filtered or unexported fields
}

Collector holds account details like keys, and allows uploading payloads.

func NewCollector

func NewCollector(apiKey, hmacKey string) (*Collector, error)

NewCollector makes a new Collector. The collectors baseURL is set based on environment variable EI_HOST if set (by prepending "https://ingestion."), otherwise defaulting to IngestionBaseURL. If you need custom HTTP handling, e.g. for proxy settings, you can override the default HTTPClient.

func (*Collector) Upload

func (c *Collector) Upload(ctx context.Context, filename string, category string, payload CollectPayload, opts *UploadOpts) (string, error)

Upload sends the payload data to EdgeImpulse for ingestion. Upload returns the name of the sample as stored in EdgeImpulse Studio. For HTTP-related errors, the (wrapped) underlying errors from net/http or an HTTPError can be returned.

type HTTPError

type HTTPError struct {
	Code   int    // HTTP status code, eg 401 or 500.
	Status string // Status message, either from body or the HTTP response status line.
}

HTTPError represents an HTTP error code and message.

func (HTTPError) Error

func (e HTTPError) Error() string

Error returns a human-readable description of the HTTP error.

type Sensor

type Sensor struct {
	Name  string `json:"name"`
	Units string `json:"units"`
}

Sensor is a sensor for which values must be sent.

type UploadOpts

type UploadOpts struct {
	Label              string
	DisallowDuplicates bool
}

UploadOpts holds payload upload options.

Jump to

Keyboard shortcuts

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