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
- Variables
- func DoFromConnection(ctx context.Context, conn rpc.ClientConn, name string, ...) (map[string]interface{}, error)
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewServer(s subtype.Service) genericpb.GenericServiceServer
- func NewUnimplementedInterfaceError(actual interface{}) error
- func RegisterService(server rpc.Server, service subtype.Service) error
- func WrapWithReconfigurable(r interface{}, name resource.Name) (resource.Reconfigurable, error)
- type Echo
- type Generic
- type Unimplemented
Constants ¶
const SubtypeName = resource.SubtypeName("generic")
SubtypeName is a constant that identifies the component resource subtype string "Generic".
Variables ¶
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} )
var Subtype = resource.NewSubtype( resource.ResourceNamespaceRDK, resource.ResourceTypeComponent, SubtypeName, )
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 NamesFromRobot ¶
NamesFromRobot is a helper for getting all generic names from the given Robot.
func NewServer ¶
func NewServer(s subtype.Service) genericpb.GenericServiceServer
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 ¶
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 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 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.