enterleavesensor

package
v0.0.0-...-084e4ab Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelOptions = []resource.Option{
	WithInitialEnterLeaveEvent(&traits.EnterLeaveEvent{
		EnterTotal: &zero,
		LeaveTotal: &zero,
	}),
}

DefaultModelOptions holds the default options for the model.

Functions

func WithEnterLeaveEventOption

func WithEnterLeaveEventOption(opts ...resource.Option) resource.Option

WithEnterLeaveEventOption configures the enterLeaveEvent resource of the model.

func WithEnterLeaveSensorApiClientFactory

func WithEnterLeaveSensorApiClientFactory(f func(name string) (traits.EnterLeaveSensorApiClient, error)) router.Option

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

func WithEnterLeaveSensorInfoClientFactory

func WithEnterLeaveSensorInfoClientFactory(f func(name string) (traits.EnterLeaveSensorInfoClient, error)) router.Option

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

func WithInitialEnterLeaveEvent

func WithInitialEnterLeaveEvent(enterLeaveEvent *traits.EnterLeaveEvent) resource.Option

WithInitialEnterLeaveEvent returns an option that configures the model to initialise with the given enter leave event.

func WrapApi

WrapApi adapts a traits.EnterLeaveSensorApiServer and presents it as a traits.EnterLeaveSensorApiClient

func WrapInfo

WrapInfo adapts a traits.EnterLeaveSensorInfoServer and presents it as a traits.EnterLeaveSensorInfoClient

Types

type ApiRouter

ApiRouter is a traits.EnterLeaveSensorApiServer that allows routing named requests to specific traits.EnterLeaveSensorApiClient

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.EnterLeaveSensorApiClient.

func (*ApiRouter) AddEnterLeaveSensorApiClient

func (r *ApiRouter) AddEnterLeaveSensorApiClient(name string, client traits.EnterLeaveSensorApiClient) traits.EnterLeaveSensorApiClient

func (*ApiRouter) GetEnterLeaveEvent

func (r *ApiRouter) GetEnterLeaveEvent(ctx context.Context, request *traits.GetEnterLeaveEventRequest) (*traits.EnterLeaveEvent, error)

func (*ApiRouter) GetEnterLeaveSensorApiClient

func (r *ApiRouter) GetEnterLeaveSensorApiClient(name string) (traits.EnterLeaveSensorApiClient, error)

func (*ApiRouter) HoldsType

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

func (*ApiRouter) Register

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

func (*ApiRouter) RemoveEnterLeaveSensorApiClient

func (r *ApiRouter) RemoveEnterLeaveSensorApiClient(name string) traits.EnterLeaveSensorApiClient

func (*ApiRouter) ResetEnterLeaveTotals

type EnterLeaveEventChange

type EnterLeaveEventChange struct {
	ChangeTime time.Time
	Value      *traits.EnterLeaveEvent
}

type InfoRouter

InfoRouter is a traits.EnterLeaveSensorInfoServer that allows routing named requests to specific traits.EnterLeaveSensorInfoClient

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.EnterLeaveSensorInfoClient.

func (*InfoRouter) AddEnterLeaveSensorInfoClient

func (r *InfoRouter) AddEnterLeaveSensorInfoClient(name string, client traits.EnterLeaveSensorInfoClient) traits.EnterLeaveSensorInfoClient

func (*InfoRouter) GetEnterLeaveSensorInfoClient

func (r *InfoRouter) GetEnterLeaveSensorInfoClient(name string) (traits.EnterLeaveSensorInfoClient, error)

func (*InfoRouter) HoldsType

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

func (*InfoRouter) Register

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

func (*InfoRouter) RemoveEnterLeaveSensorInfoClient

func (r *InfoRouter) RemoveEnterLeaveSensorInfoClient(name string) traits.EnterLeaveSensorInfoClient

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model provides the data structure for representing an EnterLeaveSensor trait.

func NewModel

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

NewModel constructs a new model with no prior enter or leave information.

func (*Model) CreateEnterLeaveEvent

func (m *Model) CreateEnterLeaveEvent(event *traits.EnterLeaveEvent, opts ...resource.WriteOption) error

CreateEnterLeaveEvent creates and publishes a new EnterLeaveEvent to Pull subscribers. The last call to CreateEnterLeaveEvent is the one that is used as the current state if Pull is called with a false updates_only field. EnterTotal and LeaveTotal will be adjusted automatically if

  1. No InterceptorBefore option is provided
  2. The events direction is either ENTER or LEAVE
  3. The event has EnterTotal or LeaveTotal equal to the current value or nil. If non-nil then the totals will be set to the passed values.

func (*Model) GetEnterLeaveEvent

func (m *Model) GetEnterLeaveEvent(opts ...resource.ReadOption) (*traits.EnterLeaveEvent, error)

func (*Model) PullEnterLeaveEvents

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

PullEnterLeaveEvents subscribes to changes in the enter leave sensor resource. The returned chan will be closed when the given context is Done.

func (*Model) ResetTotals

func (m *Model) ResetTotals() 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.UnimplementedEnterLeaveSensorApiServer
	// contains filtered or unexported fields
}

func NewModelServer

func NewModelServer(model *Model) *ModelServer

NewModelServer converts a Model into a type implementing traits.EnterLeaveSensorApiServer.

func (*ModelServer) GetEnterLeaveEvent

func (m *ModelServer) GetEnterLeaveEvent(ctx context.Context, request *traits.GetEnterLeaveEventRequest) (*traits.EnterLeaveEvent, error)

func (*ModelServer) Register

func (m *ModelServer) Register(server *grpc.Server)

func (*ModelServer) ResetEnterLeaveTotals

func (*ModelServer) Unwrap

func (m *ModelServer) Unwrap() any

Jump to

Keyboard shortcuts

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