data

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: AGPL-3.0 Imports: 17 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

This section is empty.

Variables

This section is empty.

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 InvalidInterfaceErr

func InvalidInterfaceErr(typeName resource.SubtypeName) error

InvalidInterfaceErr is the error describing when an interface not conforming to the expected resource.Subtype 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.

func (CaptureFunc) Capture

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

Capture allows any CaptureFunc to conform to the Capturer interface.

type Capturer

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

Capturer provides a function for capturing a single protobuf reading from the underlying component.

type Collector

type Collector interface {
	SetTarget(file *os.File)
	GetTarget() *os.File
	Close()
	Collect()
}

Collector collects data to some target.

func NewCollector

func NewCollector(capturer Capturer, 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        *os.File
	QueueSize     int
	BufferSize    int
	Logger        golog.Logger
}

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 MethodMetadata

type MethodMetadata struct {
	Subtype    resource.SubtypeName
	MethodName string
}

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

Jump to

Keyboard shortcuts

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