generic

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package generic contains a gRPC based generic client.

Package generic defines an abstract generic device and Do() method

Package generic contains a gRPC based generic service subtypeServer.

Index

Constants

View Source
const SubtypeName = resource.SubtypeName("generic")

SubtypeName is a constant that identifies the component resource subtype string "Generic".

Variables

View Source
var (
	ErrUnimplemented = errors.New("Do() unimplemented")
	EchoFunc         = func(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error) {
		return cmd, nil
	}
	TestCommand = map[string]interface{}{"command": "test", "data": 500}
)

Subtype is a constant that identifies the component resource subtype.

Functions

func DoFromConnection

func DoFromConnection(ctx context.Context, conn rpc.ClientConn, name string, cmd map[string]interface{}) (map[string]interface{}, error)

DoFromConnection is a helper to allow Do() calls from other component clients.

func Named

func Named(name string) resource.Name

Named is a helper for getting the named Generic's typed resource name.

func NamesFromRobot

func NamesFromRobot(r robot.Robot) []string

NamesFromRobot is a helper for getting all generic names from the given Robot.

func NewServer

NewServer constructs an generic gRPC service subtypeServer.

func RegisterService

func RegisterService(server rpc.Server, service subtype.Service)

RegisterService is a helper for testing in other components

func WrapWithReconfigurable

func WrapWithReconfigurable(r interface{}) (resource.Reconfigurable, error)

WrapWithReconfigurable converts a regular Generic implementation to a reconfigurableGeneric. If Generic is already a reconfigurableGeneric, then nothing is done.

Types

type Echo

type Echo struct{}

Echo can be embedded in other (fake) components to save boilerplate.

func (*Echo) Do

func (e *Echo) Do(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error)

Do covers the echo case for other components

type Generic

type Generic interface {
	// Do sends and recieves arbitrary data
	Do(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error)
}

Generic represents a general purpose interface

func FromRobot

func FromRobot(r robot.Robot, name string) (Generic, error)

FromRobot is a helper for getting the named Generic from the given Robot.

func NewClientFromConn

func NewClientFromConn(ctx context.Context, conn rpc.ClientConn, name string, logger golog.Logger) Generic

NewClientFromConn constructs a new Client from connection passed in.

type Unimplemented

type Unimplemented struct{}

Unimplemented can be embedded in other components to save boilerplate.

func (*Unimplemented) Do

func (u *Unimplemented) Do(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error)

Do covers the unimplemented case for other components

Directories

Path Synopsis
Package register registers the generic component
Package register registers the generic component

Jump to

Keyboard shortcuts

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