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
- 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) pb.GenericServiceServer
- func RegisterService(server rpc.Server, service subtype.Service)
- func WrapWithReconfigurable(r interface{}) (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 = 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} )
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) pb.GenericServiceServer
NewServer constructs an generic gRPC service subtypeServer.
func RegisterService ¶
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 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 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.