data

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: AGPL-3.0 Imports: 21 Imported by: 7

Documentation

Overview

Package data contains the code involved with Viam's Data Management Platform for automatically collecting component readings from robots.

Index

Constants

View Source
const FromDMString = "fromDataManagement"

FromDMString is used to access the 'fromDataManagement' value from a request's Extra struct.

Variables

View Source
var ErrNoCaptureToStore = status.Error(codes.FailedPrecondition, "no capture from filter module")

ErrNoCaptureToStore is returned when a modular filter resource filters the capture coming from the base resource.

View Source
var FromDMExtraMap = map[string]interface{}{FromDMString: true}

FromDMExtraMap is a map with 'fromDataManagement' set to true.

Functions

func FailedToReadErr

func FailedToReadErr(component, method string, err error) error

FailedToReadErr is the error describing when a Capturer was unable to get the reading of a method.

func GetExtraFromContext added in v0.8.0

func GetExtraFromContext(ctx context.Context) (*structpb.Struct, error)

GetExtraFromContext sets the extra struct with "fromDataManagement": true if the flag is true in the context. Deprecated: Use camera.FromContext instead.

func InvalidInterfaceErr

func InvalidInterfaceErr(api resource.API) error

InvalidInterfaceErr is the error describing when an interface not conforming to the expected resource.API was passed into a CollectorConstructor.

func RegisterCollector

func RegisterCollector(method MethodMetadata, c CollectorConstructor)

RegisterCollector registers a Collector to its corresponding MethodMetadata.

func RegisteredCollectors

func RegisteredCollectors() map[MethodMetadata]CollectorConstructor

RegisteredCollectors returns a copy of the registry.

Types

type CaptureFunc

type CaptureFunc func(ctx context.Context, params map[string]*anypb.Any) (interface{}, error)

CaptureFunc allows the creation of simple Capturers with anonymous functions.

type Collector

type Collector interface {
	Close()
	Collect()
	Flush()
}

Collector collects data to some target.

func NewCollector

func NewCollector(captureFunc CaptureFunc, params CollectorParams) (Collector, error)

NewCollector returns a new Collector with the passed capturer and configuration options. It calls capturer at the specified Interval, and appends the resulting reading to target.

type CollectorConstructor

type CollectorConstructor func(resource interface{}, params CollectorParams) (Collector, error)

CollectorConstructor contains a function for constructing an instance of a Collector.

func CollectorLookup

func CollectorLookup(method MethodMetadata) *CollectorConstructor

CollectorLookup looks up a Collector by the given MethodMetadata. nil is returned if there is None.

type CollectorParams

type CollectorParams struct {
	ComponentName string
	Interval      time.Duration
	MethodParams  map[string]*anypb.Any
	Target        datacapture.BufferedWriter
	QueueSize     int
	BufferSize    int
	Logger        logging.Logger
	Clock         clock.Clock
}

CollectorParams contain the parameters needed to construct a Collector.

func (CollectorParams) Validate

func (p CollectorParams) Validate() error

Validate validates that p contains all required parameters.

type FromDMContextKey added in v0.8.0

type FromDMContextKey struct{}

FromDMContextKey is used to check whether the context is from data management. Deprecated: use a camera.Extra with camera.NewContext instead.

type MethodMetadata

type MethodMetadata struct {
	API        resource.API
	MethodName string
}

MethodMetadata contains the metadata identifying a component method that we are going to capture and collect.

Directories

Path Synopsis
Package data contains the code for automatically collecting readings from robots.
Package data contains the code for automatically collecting readings from robots.

Jump to

Keyboard shortcuts

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