onoffpb

package
v0.0.0-...-ac0bb94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelOptions = []resource.Option{
	WithInitialOnOff(&traits.OnOff{}),
}

DefaultModelOptions holds the default options for the model.

Functions

func WithInitialOnOff

func WithInitialOnOff(onOff *traits.OnOff) resource.Option

WithInitialOnOff returns an option that configures the model to initialise with the given onOff.

func WithOnOffApiClientFactory

func WithOnOffApiClientFactory(f func(name string) (traits.OnOffApiClient, error)) router.Option

WithOnOffApiClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithOnOffInfoClientFactory

func WithOnOffInfoClientFactory(f func(name string) (traits.OnOffInfoClient, error)) router.Option

WithOnOffInfoClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithOnOffOption

func WithOnOffOption(opts ...resource.Option) resource.Option

WithOnOffOption configures the onOff resource of the model.

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 NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client any) any

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) GetOnOff

func (r *ApiRouter) GetOnOff(ctx context.Context, request *traits.GetOnOffRequest) (*traits.OnOff, error)

func (*ApiRouter) GetOnOffApiClient

func (r *ApiRouter) GetOnOffApiClient(name string) (traits.OnOffApiClient, error)

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client any) bool

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

func (r *ApiRouter) UpdateOnOff(ctx context.Context, request *traits.UpdateOnOffRequest) (*traits.OnOff, error)

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) GetOnOff

func (s *Group) GetOnOff(ctx context.Context, request *traits.GetOnOffRequest) (*traits.OnOff, error)

func (*Group) PullOnOff

func (s *Group) PullOnOff(request *traits.PullOnOffRequest, server traits.OnOffApi_PullOnOffServer) error

func (*Group) UpdateOnOff

func (s *Group) UpdateOnOff(ctx context.Context, request *traits.UpdateOnOffRequest) (*traits.OnOff, error)

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 NewModel

func NewModel(opts ...resource.Option) *Model

func (*Model) GetOnOff

func (m *Model) GetOnOff(opts ...resource.ReadOption) (*traits.OnOff, error)

func (*Model) PullOnOff

func (m *Model) PullOnOff(ctx context.Context, opts ...resource.ReadOption) <-chan PullOnOffChange

func (*Model) UpdateOnOff

func (m *Model) UpdateOnOff(value *traits.OnOff, opts ...resource.WriteOption) (*traits.OnOff, error)

type ModelOption

type ModelOption interface {
	resource.Option
	// contains filtered or unexported methods
}

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 (*ModelServer) PullOnOff

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)

type PullOnOffChange

type PullOnOffChange struct {
	Value      *traits.OnOff
	ChangeTime time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL