Documentation ¶
Index ¶
- Variables
- func WithInitialOccupancy(occupancy *traits.Occupancy) resource.Option
- func WithOccupancyOption(opts ...resource.Option) resource.Option
- func WithOccupancySensorApiClientFactory(f func(name string) (traits.OccupancySensorApiClient, error)) router.Option
- func WithOccupancySensorInfoClientFactory(f func(name string) (traits.OccupancySensorInfoClient, error)) router.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddOccupancySensorApiClient(name string, client traits.OccupancySensorApiClient) traits.OccupancySensorApiClient
- func (r *ApiRouter) GetOccupancy(ctx context.Context, request *traits.GetOccupancyRequest) (*traits.Occupancy, error)
- func (r *ApiRouter) GetOccupancySensorApiClient(name string) (traits.OccupancySensorApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) PullOccupancy(request *traits.PullOccupancyRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveOccupancySensorApiClient(name string) traits.OccupancySensorApiClient
- type ApiWrapper
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddOccupancySensorInfoClient(name string, client traits.OccupancySensorInfoClient) traits.OccupancySensorInfoClient
- func (r *InfoRouter) DescribeOccupancy(ctx context.Context, request *traits.DescribeOccupancyRequest) (*traits.OccupancySupport, error)
- func (r *InfoRouter) GetOccupancySensorInfoClient(name string) (traits.OccupancySensorInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveOccupancySensorInfoClient(name string) traits.OccupancySensorInfoClient
- type InfoWrapper
- type Model
- func (m *Model) GetOccupancy(opts ...resource.ReadOption) (*traits.Occupancy, error)
- func (m *Model) PullOccupancy(ctx context.Context, opts ...resource.ReadOption) <-chan PullOccupancyChange
- func (m *Model) SetOccupancy(occupancy *traits.Occupancy, opts ...resource.WriteOption) (*traits.Occupancy, error)
- type ModelOption
- type ModelServer
- type PullOccupancyChange
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithInitialOccupancy(&traits.Occupancy{}), }
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithInitialOccupancy ¶
WithInitialOccupancy returns an option that configures the model to initialise with the given occupancy.
func WithOccupancyOption ¶
WithOccupancyOption configures the occupancy resource of the model.
func WithOccupancySensorApiClientFactory ¶
func WithOccupancySensorApiClientFactory(f func(name string) (traits.OccupancySensorApiClient, error)) router.Option
WithOccupancySensorApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithOccupancySensorInfoClientFactory ¶
func WithOccupancySensorInfoClientFactory(f func(name string) (traits.OccupancySensorInfoClient, error)) router.Option
WithOccupancySensorInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedOccupancySensorApiServer router.Router }
ApiRouter is a traits.OccupancySensorApiServer that allows routing named requests to specific traits.OccupancySensorApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.OccupancySensorApiClient.
func (*ApiRouter) AddOccupancySensorApiClient ¶
func (r *ApiRouter) AddOccupancySensorApiClient(name string, client traits.OccupancySensorApiClient) traits.OccupancySensorApiClient
func (*ApiRouter) GetOccupancy ¶
func (*ApiRouter) GetOccupancySensorApiClient ¶
func (r *ApiRouter) GetOccupancySensorApiClient(name string) (traits.OccupancySensorApiClient, error)
func (*ApiRouter) PullOccupancy ¶
func (r *ApiRouter) PullOccupancy(request *traits.PullOccupancyRequest, server traits.OccupancySensorApi_PullOccupancyServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveOccupancySensorApiClient ¶
func (r *ApiRouter) RemoveOccupancySensorApiClient(name string) traits.OccupancySensorApiClient
type ApiWrapper ¶
type ApiWrapper struct { traits.OccupancySensorApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.OccupancySensorApiServer) *ApiWrapper
WrapApi adapts a traits.OccupancySensorApiServer and presents it as a traits.OccupancySensorApiClient
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.OccupancySensorApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedOccupancySensorInfoServer router.Router }
InfoRouter is a traits.OccupancySensorInfoServer that allows routing named requests to specific traits.OccupancySensorInfoClient
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.OccupancySensorInfoClient.
func (*InfoRouter) AddOccupancySensorInfoClient ¶
func (r *InfoRouter) AddOccupancySensorInfoClient(name string, client traits.OccupancySensorInfoClient) traits.OccupancySensorInfoClient
func (*InfoRouter) DescribeOccupancy ¶
func (r *InfoRouter) DescribeOccupancy(ctx context.Context, request *traits.DescribeOccupancyRequest) (*traits.OccupancySupport, error)
func (*InfoRouter) GetOccupancySensorInfoClient ¶
func (r *InfoRouter) GetOccupancySensorInfoClient(name string) (traits.OccupancySensorInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveOccupancySensorInfoClient ¶
func (r *InfoRouter) RemoveOccupancySensorInfoClient(name string) traits.OccupancySensorInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.OccupancySensorInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.OccupancySensorInfoServer) *InfoWrapper
WrapInfo adapts a traits.OccupancySensorInfoServer and presents it as a traits.OccupancySensorInfoClient
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.OccupancySensorInfoServer
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) GetOccupancy ¶
func (*Model) PullOccupancy ¶
func (m *Model) PullOccupancy(ctx context.Context, opts ...resource.ReadOption) <-chan PullOccupancyChange
func (*Model) SetOccupancy ¶
func (m *Model) SetOccupancy(occupancy *traits.Occupancy, opts ...resource.WriteOption) (*traits.Occupancy, error)
SetOccupancy updates the known occupancy state for this device
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedOccupancySensorApiServer // contains filtered or unexported fields }
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) GetOccupancy ¶
func (s *ModelServer) GetOccupancy(_ context.Context, req *traits.GetOccupancyRequest) (*traits.Occupancy, error)
func (*ModelServer) PullOccupancy ¶
func (s *ModelServer) PullOccupancy(request *traits.PullOccupancyRequest, server traits.OccupancySensorApi_PullOccupancyServer) error
func (*ModelServer) Register ¶
func (s *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) Unwrap ¶
func (s *ModelServer) Unwrap() any