types

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package types contains the types and associated methods for the state service.

Index

Constants

View Source
const (
	// SerdeDomain is a copy of the state service's serde domain, from
	// orc8r/cloud/go/services/state/doc.go.
	SerdeDomain = "state"
)

Variables

This section is empty.

Functions

func MakeProtoState

func MakeProtoState(id ID, st State) (*protos.State, error)

MakeProtoState converts a state and ID to a proto state.

func MakeProtoStateErrors

func MakeProtoStateErrors(errs StateErrors) []*protos.IDAndError

MakeProtoStateErrors converts state errors to proto state errors.

func MakeProtoStates

func MakeProtoStates(states StatesByID) ([]*protos.State, error)

MakeProtoStates converts states by ID to proto states.

Types

type ID

type ID struct {
	// Type determines how the value is deserialized and validated on the cloud service side.
	Type string
	// DeviceID is the ID of the entity with which the state is associated (IMSI, serial number, etc).
	DeviceID string
}

ID identifies a piece of state. A piece of state is uniquely identified by the triplet {network ID, device ID, type}.

type IDsByNetwork

type IDsByNetwork map[string][]ID

IDsByNetwork are a set of state IDs, keyed by network ID.

type SerializedStateWithMeta

type SerializedStateWithMeta struct {
	ReporterID              string
	TimeMs                  uint64
	CertExpirationTime      int64
	SerializedReportedState []byte
	Version                 uint64
}

SerializedStateWithMeta includes reported operational states and additional info

type State

type State struct {
	// ReportedState is the actual state reported by the device.
	ReportedState interface{}

	// Type determines how the reported state value is deserialized and validated on the cloud service side.
	Type string
	// Version is the reported version of the state.
	Version uint64
	// ReporterID is the hardware ID of the gateway which reported the state.
	ReporterID string
	// TimeMs is the time the state was received in milliseconds.
	TimeMs uint64
	// CertExpirationTime is the expiration time in milliseconds.
	CertExpirationTime int64
}

State includes reported operational state and additional info about the reporter.

func MakeState

func MakeState(p *protos.State) (State, error)

MakeState converts a proto state to a native state.

type StateErrors

type StateErrors map[ID]error

StateErrors is a mapping of state ID to error experienced handling the state.

func MakeStateErrors

func MakeStateErrors(errs []*protos.IDAndError) StateErrors

MakeStateErrors converts proto state errors to native state errors.

type StatesByID

type StatesByID map[ID]State

StatesByID maps state IDs to state. A state and its ID collectively contains all information for a piece of state.

func MakeStatesByID

func MakeStatesByID(states []*protos.State) (StatesByID, error)

MakeStatesByID converts proto states to native states keyed by state ID.

Jump to

Keyboard shortcuts

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