Documentation
¶
Index ¶
- Variables
- func InitialBrightness() *traits.Brightness
- func WithBrightnessOption(opts ...resource.Option) resource.Option
- func WithInitialBrightness(brightness *traits.Brightness) resource.Option
- func WithLightApiClientFactory(f func(name string) (traits.LightApiClient, error)) router.Option
- func WithLightInfoClientFactory(f func(name string) (traits.LightInfoClient, error)) router.Option
- func WithPreset(levelPercent float32, p *traits.LightPreset) resource.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddLightApiClient(name string, client traits.LightApiClient) traits.LightApiClient
- func (r *ApiRouter) GetBrightness(ctx context.Context, request *traits.GetBrightnessRequest) (*traits.Brightness, error)
- func (r *ApiRouter) GetLightApiClient(name string) (traits.LightApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) PullBrightness(request *traits.PullBrightnessRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveLightApiClient(name string) traits.LightApiClient
- func (r *ApiRouter) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
- type ApiWrapper
- type Group
- func (s *Group) GetBrightness(ctx context.Context, request *traits.GetBrightnessRequest) (*traits.Brightness, error)
- func (s *Group) PullBrightness(request *traits.PullBrightnessRequest, ...) error
- func (s *Group) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddLightInfoClient(name string, client traits.LightInfoClient) traits.LightInfoClient
- func (r *InfoRouter) DescribeBrightness(ctx context.Context, request *traits.DescribeBrightnessRequest) (*traits.BrightnessSupport, error)
- func (r *InfoRouter) GetLightInfoClient(name string) (traits.LightInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveLightInfoClient(name string) traits.LightInfoClient
- type InfoWrapper
- type MemoryDevice
- func (s *MemoryDevice) GetBrightness(_ context.Context, req *traits.GetBrightnessRequest) (*traits.Brightness, error)
- func (s *MemoryDevice) PullBrightness(request *traits.PullBrightnessRequest, ...) error
- func (s *MemoryDevice) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
- type Model
- func (m *Model) GetBrightness(opts ...resource.ReadOption) (*traits.Brightness, error)
- func (m *Model) ListPresets() []*traits.LightPreset
- func (m *Model) PullBrightness(ctx context.Context, opts ...resource.ReadOption) <-chan PullBrightnessChange
- func (m *Model) UpdateBrightness(light *traits.Brightness, opts ...resource.WriteOption) (*traits.Brightness, error)
- type ModelOption
- type ModelServer
- func (s *ModelServer) DescribeBrightness(_ context.Context, _ *traits.DescribeBrightnessRequest) (*traits.BrightnessSupport, error)
- func (s *ModelServer) GetBrightness(_ context.Context, req *traits.GetBrightnessRequest) (*traits.Brightness, error)
- func (s *ModelServer) PullBrightness(request *traits.PullBrightnessRequest, ...) error
- func (s *ModelServer) Register(server grpc.ServiceRegistrar)
- func (s *ModelServer) Unwrap() any
- func (s *ModelServer) UpdateBrightness(_ context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
- type PullBrightnessChange
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithInitialBrightness(&traits.Brightness{}), }
DefaultModelOptions holds the default options for the model.
Functions ¶
func InitialBrightness ¶
func InitialBrightness() *traits.Brightness
func WithBrightnessOption ¶
WithBrightnessOption configures the brightness resource of the model.
func WithInitialBrightness ¶
func WithInitialBrightness(brightness *traits.Brightness) resource.Option
WithInitialBrightness returns an option that configures the model to initialise with the given brightness.
func WithLightApiClientFactory ¶
WithLightApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithLightInfoClientFactory ¶
WithLightInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithPreset ¶
func WithPreset(levelPercent float32, p *traits.LightPreset) resource.Option
WithPreset instructs the model to set the light to the given level when preset p is selected.
Types ¶
type ApiRouter ¶
type ApiRouter struct {
traits.UnimplementedLightApiServer
router.Router
}
ApiRouter is a traits.LightApiServer that allows routing named requests to specific traits.LightApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.LightApiClient.
func (*ApiRouter) AddLightApiClient ¶
func (r *ApiRouter) AddLightApiClient(name string, client traits.LightApiClient) traits.LightApiClient
func (*ApiRouter) GetBrightness ¶
func (r *ApiRouter) GetBrightness(ctx context.Context, request *traits.GetBrightnessRequest) (*traits.Brightness, error)
func (*ApiRouter) GetLightApiClient ¶
func (r *ApiRouter) GetLightApiClient(name string) (traits.LightApiClient, error)
func (*ApiRouter) PullBrightness ¶
func (r *ApiRouter) PullBrightness(request *traits.PullBrightnessRequest, server traits.LightApi_PullBrightnessServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveLightApiClient ¶
func (r *ApiRouter) RemoveLightApiClient(name string) traits.LightApiClient
func (*ApiRouter) UpdateBrightness ¶
func (r *ApiRouter) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
type ApiWrapper ¶
type ApiWrapper struct {
traits.LightApiClient
// contains filtered or unexported fields
}
func WrapApi ¶
func WrapApi(server traits.LightApiServer) *ApiWrapper
WrapApi adapts a traits.LightApiServer and presents it as a traits.LightApiClient
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.LightApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type Group ¶
type Group struct {
traits.UnimplementedLightApiServer
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.LightApiClient, members ...string) *Group
NewGroup creates a new Group instance with ExecutionStrategyAll for both reads and writes.
func (*Group) GetBrightness ¶
func (s *Group) GetBrightness(ctx context.Context, request *traits.GetBrightnessRequest) (*traits.Brightness, error)
func (*Group) PullBrightness ¶
func (s *Group) PullBrightness(request *traits.PullBrightnessRequest, server traits.LightApi_PullBrightnessServer) error
func (*Group) UpdateBrightness ¶
func (s *Group) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
type InfoRouter ¶
type InfoRouter struct {
traits.UnimplementedLightInfoServer
router.Router
}
InfoRouter is a traits.LightInfoServer that allows routing named requests to specific traits.LightInfoClient
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.LightInfoClient.
func (*InfoRouter) AddLightInfoClient ¶
func (r *InfoRouter) AddLightInfoClient(name string, client traits.LightInfoClient) traits.LightInfoClient
func (*InfoRouter) DescribeBrightness ¶
func (r *InfoRouter) DescribeBrightness(ctx context.Context, request *traits.DescribeBrightnessRequest) (*traits.BrightnessSupport, error)
func (*InfoRouter) GetLightInfoClient ¶
func (r *InfoRouter) GetLightInfoClient(name string) (traits.LightInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveLightInfoClient ¶
func (r *InfoRouter) RemoveLightInfoClient(name string) traits.LightInfoClient
type InfoWrapper ¶
type InfoWrapper struct {
traits.LightInfoClient
// contains filtered or unexported fields
}
func WrapInfo ¶
func WrapInfo(server traits.LightInfoServer) *InfoWrapper
WrapInfo adapts a traits.LightInfoServer and presents it as a traits.LightInfoClient
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.LightInfoServer
UnwrapServer returns the underlying server instance.
func (*InfoWrapper) UnwrapService ¶
func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type MemoryDevice ¶
type MemoryDevice struct {
traits.UnimplementedLightApiServer
// contains filtered or unexported fields
}
MemoryDevice implements the LightApiServer interface for a single device by storing state in memory.
func NewMemoryDevice ¶
func NewMemoryDevice() *MemoryDevice
func (*MemoryDevice) GetBrightness ¶
func (s *MemoryDevice) GetBrightness(_ context.Context, req *traits.GetBrightnessRequest) (*traits.Brightness, error)
func (*MemoryDevice) PullBrightness ¶
func (s *MemoryDevice) PullBrightness(request *traits.PullBrightnessRequest, server traits.LightApi_PullBrightnessServer) error
func (*MemoryDevice) UpdateBrightness ¶
func (s *MemoryDevice) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) GetBrightness ¶
func (m *Model) GetBrightness(opts ...resource.ReadOption) (*traits.Brightness, error)
func (*Model) ListPresets ¶
func (m *Model) ListPresets() []*traits.LightPreset
func (*Model) PullBrightness ¶
func (m *Model) PullBrightness(ctx context.Context, opts ...resource.ReadOption) <-chan PullBrightnessChange
func (*Model) UpdateBrightness ¶
func (m *Model) UpdateBrightness(light *traits.Brightness, opts ...resource.WriteOption) (*traits.Brightness, error)
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct {
traits.UnimplementedLightApiServer
traits.UnimplementedLightInfoServer
// contains filtered or unexported fields
}
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) DescribeBrightness ¶
func (s *ModelServer) DescribeBrightness(_ context.Context, _ *traits.DescribeBrightnessRequest) (*traits.BrightnessSupport, error)
func (*ModelServer) GetBrightness ¶
func (s *ModelServer) GetBrightness(_ context.Context, req *traits.GetBrightnessRequest) (*traits.Brightness, error)
func (*ModelServer) PullBrightness ¶
func (s *ModelServer) PullBrightness(request *traits.PullBrightnessRequest, server traits.LightApi_PullBrightnessServer) error
func (*ModelServer) Register ¶
func (s *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) Unwrap ¶
func (s *ModelServer) Unwrap() any
func (*ModelServer) UpdateBrightness ¶
func (s *ModelServer) UpdateBrightness(_ context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)
type PullBrightnessChange ¶
type PullBrightnessChange struct {
Value *traits.Brightness
ChangeTime time.Time
}