Documentation ¶
Index ¶
- Variables
- func WithFanSpeedApiClientFactory(f func(name string) (traits.FanSpeedApiClient, error)) router.Option
- func WithFanSpeedInfoClientFactory(f func(name string) (traits.FanSpeedInfoClient, error)) router.Option
- func WithFanSpeedOption(opts ...resource.Option) resource.Option
- func WithInitialFanSpeed(fanSpeed *traits.FanSpeed) resource.Option
- func WithPresets(presets ...Preset) resource.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddFanSpeedApiClient(name string, client traits.FanSpeedApiClient) traits.FanSpeedApiClient
- func (r *ApiRouter) GetFanSpeed(ctx context.Context, request *traits.GetFanSpeedRequest) (*traits.FanSpeed, error)
- func (r *ApiRouter) GetFanSpeedApiClient(name string) (traits.FanSpeedApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) PullFanSpeed(request *traits.PullFanSpeedRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveFanSpeedApiClient(name string) traits.FanSpeedApiClient
- func (r *ApiRouter) ReverseFanSpeedDirection(ctx context.Context, request *traits.ReverseFanSpeedDirectionRequest) (*traits.FanSpeed, error)
- func (r *ApiRouter) UpdateFanSpeed(ctx context.Context, request *traits.UpdateFanSpeedRequest) (*traits.FanSpeed, error)
- type ApiWrapper
- type FanSpeedChange
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddFanSpeedInfoClient(name string, client traits.FanSpeedInfoClient) traits.FanSpeedInfoClient
- func (r *InfoRouter) DescribeFanSpeed(ctx context.Context, request *traits.DescribeFanSpeedRequest) (*traits.FanSpeedSupport, error)
- func (r *InfoRouter) GetFanSpeedInfoClient(name string) (traits.FanSpeedInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveFanSpeedInfoClient(name string) traits.FanSpeedInfoClient
- type InfoWrapper
- type Model
- func (m *Model) DeriveValues(old, new proto.Message)
- func (m *Model) FanSpeed(opts ...resource.ReadOption) *traits.FanSpeed
- func (m *Model) PullFanSpeed(ctx context.Context, opts ...resource.ReadOption) <-chan FanSpeedChange
- func (m *Model) UpdateFanSpeed(fanSpeed *traits.FanSpeed, opts ...resource.WriteOption) (*traits.FanSpeed, error)
- type ModelOption
- type ModelServer
- func (s *ModelServer) GetFanSpeed(_ context.Context, request *traits.GetFanSpeedRequest) (*traits.FanSpeed, error)
- func (s *ModelServer) PullFanSpeed(request *traits.PullFanSpeedRequest, ...) error
- func (s *ModelServer) Register(server grpc.ServiceRegistrar)
- func (s *ModelServer) ReverseFanSpeedDirection(ctx context.Context, request *traits.ReverseFanSpeedDirectionRequest) (*traits.FanSpeed, error)
- func (s *ModelServer) Unwrap() any
- func (s *ModelServer) UpdateFanSpeed(_ context.Context, request *traits.UpdateFanSpeedRequest) (*traits.FanSpeed, error)
- type Preset
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithInitialFanSpeed(&traits.FanSpeed{ Percentage: DefaultPresets[0].Percentage, Preset: DefaultPresets[0].Name, Direction: traits.FanSpeed_FORWARD, }), WithFanSpeedOption(resource.WithMessageEquivalence(cmp.Equal(cmp.FloatValueApprox(0, 0.01)))), WithPresets(DefaultPresets...), }
DefaultModelOptions holds the default options for the model.
var DefaultPresets = []Preset{
{Name: "off", Percentage: 0},
{Name: "low", Percentage: 15},
{Name: "med", Percentage: 40},
{Name: "high", Percentage: 75},
{Name: "full", Percentage: 100},
}
Functions ¶
func WithFanSpeedApiClientFactory ¶
func WithFanSpeedApiClientFactory(f func(name string) (traits.FanSpeedApiClient, error)) router.Option
WithFanSpeedApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithFanSpeedInfoClientFactory ¶
func WithFanSpeedInfoClientFactory(f func(name string) (traits.FanSpeedInfoClient, error)) router.Option
WithFanSpeedInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithFanSpeedOption ¶
WithFanSpeedOption configures the fanSpeed resource of the model.
func WithInitialFanSpeed ¶
WithInitialFanSpeed returns an option that configures the model to initialise with the given fan speed.
func WithPresets ¶
WithPresets returns an option that configures the model to use the given presets.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedFanSpeedApiServer router.Router }
ApiRouter is a traits.FanSpeedApiServer that allows routing named requests to specific traits.FanSpeedApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.FanSpeedApiClient.
func (*ApiRouter) AddFanSpeedApiClient ¶
func (r *ApiRouter) AddFanSpeedApiClient(name string, client traits.FanSpeedApiClient) traits.FanSpeedApiClient
func (*ApiRouter) GetFanSpeed ¶
func (*ApiRouter) GetFanSpeedApiClient ¶
func (r *ApiRouter) GetFanSpeedApiClient(name string) (traits.FanSpeedApiClient, error)
func (*ApiRouter) PullFanSpeed ¶
func (r *ApiRouter) PullFanSpeed(request *traits.PullFanSpeedRequest, server traits.FanSpeedApi_PullFanSpeedServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveFanSpeedApiClient ¶
func (r *ApiRouter) RemoveFanSpeedApiClient(name string) traits.FanSpeedApiClient
func (*ApiRouter) ReverseFanSpeedDirection ¶
func (*ApiRouter) UpdateFanSpeed ¶
type ApiWrapper ¶
type ApiWrapper struct { traits.FanSpeedApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.FanSpeedApiServer) *ApiWrapper
WrapApi adapts a traits.FanSpeedApiServer and presents it as a traits.FanSpeedApiClient
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.FanSpeedApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedFanSpeedInfoServer router.Router }
InfoRouter is a traits.FanSpeedInfoServer that allows routing named requests to specific traits.FanSpeedInfoClient
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.FanSpeedInfoClient.
func (*InfoRouter) AddFanSpeedInfoClient ¶
func (r *InfoRouter) AddFanSpeedInfoClient(name string, client traits.FanSpeedInfoClient) traits.FanSpeedInfoClient
func (*InfoRouter) DescribeFanSpeed ¶
func (r *InfoRouter) DescribeFanSpeed(ctx context.Context, request *traits.DescribeFanSpeedRequest) (*traits.FanSpeedSupport, error)
func (*InfoRouter) GetFanSpeedInfoClient ¶
func (r *InfoRouter) GetFanSpeedInfoClient(name string) (traits.FanSpeedInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveFanSpeedInfoClient ¶
func (r *InfoRouter) RemoveFanSpeedInfoClient(name string) traits.FanSpeedInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.FanSpeedInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.FanSpeedInfoServer) *InfoWrapper
WrapInfo adapts a traits.FanSpeedInfoServer and presents it as a traits.FanSpeedInfoClient
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.FanSpeedInfoServer
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
}
Model provides a data structure for supporting the Fan Speed trait. Unless configured otherwise, this model supports DefaultPresets presets.
func (*Model) DeriveValues ¶
DeriveValues derives values that haven't been set from those that have. For example setting percentage when the preset changes. Updated values will be set on new.
func (*Model) FanSpeed ¶
func (m *Model) FanSpeed(opts ...resource.ReadOption) *traits.FanSpeed
FanSpeed gets the current fan speed.
func (*Model) PullFanSpeed ¶
func (m *Model) PullFanSpeed(ctx context.Context, opts ...resource.ReadOption) <-chan FanSpeedChange
func (*Model) UpdateFanSpeed ¶
func (m *Model) UpdateFanSpeed(fanSpeed *traits.FanSpeed, opts ...resource.WriteOption) (*traits.FanSpeed, error)
UpdateFanSpeed changes the fan speed. Provide write options to support features like relative changes. Related properties of the fan speed will be set automatically, for example if the preset changes then the percentage and preset index are also changed. Providing a resource.InterceptAfter option will disable related property updating. Using DeriveValues can re-enable related property computation if needed.
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedFanSpeedApiServer // contains filtered or unexported fields }
ModelServer adapts a Model as a traits.FanSpeedApiServer.
func NewModelServer ¶
func NewModelServer(model *Model) *ModelServer
func (*ModelServer) GetFanSpeed ¶
func (s *ModelServer) GetFanSpeed(_ context.Context, request *traits.GetFanSpeedRequest) (*traits.FanSpeed, error)
func (*ModelServer) PullFanSpeed ¶
func (s *ModelServer) PullFanSpeed(request *traits.PullFanSpeedRequest, server traits.FanSpeedApi_PullFanSpeedServer) error
func (*ModelServer) Register ¶
func (s *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) ReverseFanSpeedDirection ¶
func (s *ModelServer) ReverseFanSpeedDirection(ctx context.Context, request *traits.ReverseFanSpeedDirectionRequest) (*traits.FanSpeed, error)
func (*ModelServer) Unwrap ¶
func (s *ModelServer) Unwrap() any
func (*ModelServer) UpdateFanSpeed ¶
func (s *ModelServer) UpdateFanSpeed(_ context.Context, request *traits.UpdateFanSpeedRequest) (*traits.FanSpeed, error)