Documentation
¶
Index ¶
- Variables
- func WithInitialOnOff(onOff *traits.OnOff) resource.Option
- func WithOnOffApiClientFactory(f func(name string) (traits.OnOffApiClient, error)) router.Option
- func WithOnOffInfoClientFactory(f func(name string) (traits.OnOffInfoClient, error)) router.Option
- func WithOnOffOption(opts ...resource.Option) resource.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddOnOffApiClient(name string, client traits.OnOffApiClient) traits.OnOffApiClient
- func (r *ApiRouter) GetOnOff(ctx context.Context, request *traits.GetOnOffRequest) (*traits.OnOff, error)
- func (r *ApiRouter) GetOnOffApiClient(name string) (traits.OnOffApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveOnOffApiClient(name string) traits.OnOffApiClient
- func (r *ApiRouter) UpdateOnOff(ctx context.Context, request *traits.UpdateOnOffRequest) (*traits.OnOff, error)
- type ApiWrapper
- type Group
- func (s *Group) GetOnOff(ctx context.Context, request *traits.GetOnOffRequest) (*traits.OnOff, error)
- func (s *Group) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error
- func (s *Group) UpdateOnOff(ctx context.Context, request *traits.UpdateOnOffRequest) (*traits.OnOff, error)
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddOnOffInfoClient(name string, client traits.OnOffInfoClient) traits.OnOffInfoClient
- func (r *InfoRouter) DescribeOnOff(ctx context.Context, request *traits.DescribeOnOffRequest) (*traits.OnOffSupport, error)
- func (r *InfoRouter) GetOnOffInfoClient(name string) (traits.OnOffInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveOnOffInfoClient(name string) traits.OnOffInfoClient
- type InfoWrapper
- type Model
- type ModelOption
- type ModelServer
- func (s *ModelServer) GetOnOff(_ context.Context, req *traits.GetOnOffRequest) (*traits.OnOff, error)
- func (s *ModelServer) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error
- func (s *ModelServer) Register(server grpc.ServiceRegistrar)
- func (s *ModelServer) Unwrap() any
- func (s *ModelServer) UpdateOnOff(_ context.Context, request *traits.UpdateOnOffRequest) (*traits.OnOff, error)
- type PullOnOffChange
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithInitialOnOff(&traits.OnOff{}), }
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithInitialOnOff ¶
WithInitialOnOff returns an option that configures the model to initialise with the given onOff.
func WithOnOffApiClientFactory ¶
WithOnOffApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithOnOffInfoClientFactory ¶
WithOnOffInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedOnOffApiServer router.Router }
ApiRouter is a traits.OnOffApiServer that allows routing named requests to specific traits.OnOffApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.OnOffApiClient.
func (*ApiRouter) AddOnOffApiClient ¶
func (r *ApiRouter) AddOnOffApiClient(name string, client traits.OnOffApiClient) traits.OnOffApiClient
func (*ApiRouter) GetOnOffApiClient ¶
func (r *ApiRouter) GetOnOffApiClient(name string) (traits.OnOffApiClient, error)
func (*ApiRouter) PullOnOff ¶
func (r *ApiRouter) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveOnOffApiClient ¶
func (r *ApiRouter) RemoveOnOffApiClient(name string) traits.OnOffApiClient
func (*ApiRouter) UpdateOnOff ¶
type ApiWrapper ¶
type ApiWrapper struct { traits.OnOffApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.OnOffApiServer) *ApiWrapper
WrapApi adapts a traits.OnOffApiServer and presents it as a traits.OnOffApiClient
func (*ApiWrapper) Unwrap ¶
func (w *ApiWrapper) Unwrap() any
Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.
func (*ApiWrapper) UnwrapServer ¶
func (w *ApiWrapper) UnwrapServer() traits.OnOffApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type Group ¶
type Group struct { traits.UnimplementedOnOffApiServer ReadExecution group.ExecutionStrategy WriteExecution group.ExecutionStrategy // contains filtered or unexported fields }
Group combines multiple named devices into a single named device.
func NewGroup ¶
func NewGroup(impl traits.OnOffApiClient, members ...string) *Group
NewGroup creates a new Group instance with ExecutionStrategyAll for both reads and writes.
func (*Group) PullOnOff ¶
func (s *Group) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error
func (*Group) UpdateOnOff ¶
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedOnOffInfoServer router.Router }
InfoRouter is a traits.OnOffInfoServer that allows routing named requests to specific traits.OnOffInfoClient
func NewInfoRouter ¶
func NewInfoRouter(opts ...router.Option) *InfoRouter
func (*InfoRouter) Add ¶
func (r *InfoRouter) Add(name string, client any) any
Add extends Router.Add to panic if client is not of type traits.OnOffInfoClient.
func (*InfoRouter) AddOnOffInfoClient ¶
func (r *InfoRouter) AddOnOffInfoClient(name string, client traits.OnOffInfoClient) traits.OnOffInfoClient
func (*InfoRouter) DescribeOnOff ¶
func (r *InfoRouter) DescribeOnOff(ctx context.Context, request *traits.DescribeOnOffRequest) (*traits.OnOffSupport, error)
func (*InfoRouter) GetOnOffInfoClient ¶
func (r *InfoRouter) GetOnOffInfoClient(name string) (traits.OnOffInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveOnOffInfoClient ¶
func (r *InfoRouter) RemoveOnOffInfoClient(name string) traits.OnOffInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.OnOffInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.OnOffInfoServer) *InfoWrapper
WrapInfo adapts a traits.OnOffInfoServer and presents it as a traits.OnOffInfoClient
func (*InfoWrapper) Unwrap ¶
func (w *InfoWrapper) Unwrap() any
Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.
func (*InfoWrapper) UnwrapServer ¶
func (w *InfoWrapper) UnwrapServer() traits.OnOffInfoServer
UnwrapServer returns the underlying server instance.
func (*InfoWrapper) UnwrapService ¶
func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) PullOnOff ¶
func (m *Model) PullOnOff(ctx context.Context, opts ...resource.ReadOption) <-chan PullOnOffChange
func (*Model) UpdateOnOff ¶
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedOnOffApiServer // contains filtered or unexported fields }
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) GetOnOff ¶
func (s *ModelServer) GetOnOff(_ context.Context, req *traits.GetOnOffRequest) (*traits.OnOff, error)
func (*ModelServer) PullOnOff ¶
func (s *ModelServer) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error
func (*ModelServer) Register ¶
func (s *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) Unwrap ¶
func (s *ModelServer) Unwrap() any
func (*ModelServer) UpdateOnOff ¶
func (s *ModelServer) UpdateOnOff(_ context.Context, request *traits.UpdateOnOffRequest) (*traits.OnOff, error)