light

package
v0.0.0-...-8d9afb2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitialBrightness

func InitialBrightness() *traits.Brightness

func WithLightApiClientFactory

func WithLightApiClientFactory(f func(name string) (traits.LightApiClient, error)) router.Option

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

func WithLightInfoClientFactory

func WithLightInfoClientFactory(f func(name string) (traits.LightInfoClient, error)) router.Option

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

func WrapApi

WrapApi adapts a traits.LightApiServer and presents it as a traits.LightApiClient

func WrapInfo

WrapInfo adapts a traits.LightInfoServer and presents it as a traits.LightInfoClient

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 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.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) HoldsType

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

func (*ApiRouter) PullBrightness

func (*ApiRouter) Register

func (r *ApiRouter) Register(server *grpc.Server)

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 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.Server)

func (*InfoRouter) RemoveLightInfoClient

func (r *InfoRouter) RemoveLightInfoClient(name string) traits.LightInfoClient

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 (*MemoryDevice) PullBrightness

func (*MemoryDevice) UpdateBrightness

func (s *MemoryDevice) UpdateBrightness(ctx context.Context, request *traits.UpdateBrightnessRequest) (*traits.Brightness, error)

Jump to

Keyboard shortcuts

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