generic

package
v0.2.35 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: AGPL-3.0 Imports: 15 Imported by: 14

Documentation

Overview

Package generic contains a gRPC based generic client.

Package generic defines an abstract generic device and DoCommand() 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 is returned if the DoCommand methods is not implemented.
	ErrUnimplemented = errors.New("DoCommand() unimplemented")

	// EchoFunc is a helper to echo out the say command passsed in a Do.
	EchoFunc = func(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error) {
		return cmd, nil
	}

	// TestCommand is a dummy command to send for a DoCommand.
	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 NewUnimplementedInterfaceError

func NewUnimplementedInterfaceError(actual interface{}) error

NewUnimplementedInterfaceError is used when there is a failed interface check.

func RegisterService

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

RegisterService is a helper for testing in other components.

func WrapWithReconfigurable

func WrapWithReconfigurable(r interface{}, name resource.Name) (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) DoCommand

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

DoCommand covers the echo case for other components.

type Generic

type Generic interface {
	// DoCommand sends and receives arbitrary data
	DoCommand(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) DoCommand

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

DoCommand covers the unimplemented case for other components.

Directories

Path Synopsis
Package fake implements a fake Generic component.
Package fake implements a fake Generic component.
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