Documentation ¶
Index ¶
- Variables
- func WithEnterLeaveEventOption(opts ...resource.Option) resource.Option
- func WithEnterLeaveSensorApiClientFactory(f func(name string) (traits.EnterLeaveSensorApiClient, error)) router.Option
- func WithEnterLeaveSensorInfoClientFactory(f func(name string) (traits.EnterLeaveSensorInfoClient, error)) router.Option
- func WithInitialEnterLeaveEvent(enterLeaveEvent *traits.EnterLeaveEvent) resource.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddEnterLeaveSensorApiClient(name string, client traits.EnterLeaveSensorApiClient) traits.EnterLeaveSensorApiClient
- func (r *ApiRouter) GetEnterLeaveEvent(ctx context.Context, request *traits.GetEnterLeaveEventRequest) (*traits.EnterLeaveEvent, error)
- func (r *ApiRouter) GetEnterLeaveSensorApiClient(name string) (traits.EnterLeaveSensorApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) PullEnterLeaveEvents(request *traits.PullEnterLeaveEventsRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveEnterLeaveSensorApiClient(name string) traits.EnterLeaveSensorApiClient
- func (r *ApiRouter) ResetEnterLeaveTotals(ctx context.Context, request *traits.ResetEnterLeaveTotalsRequest) (*traits.ResetEnterLeaveTotalsResponse, error)
- type ApiWrapper
- type EnterLeaveEventChange
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddEnterLeaveSensorInfoClient(name string, client traits.EnterLeaveSensorInfoClient) traits.EnterLeaveSensorInfoClient
- func (r *InfoRouter) GetEnterLeaveSensorInfoClient(name string) (traits.EnterLeaveSensorInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveEnterLeaveSensorInfoClient(name string) traits.EnterLeaveSensorInfoClient
- type InfoWrapper
- type Model
- func (m *Model) CreateEnterLeaveEvent(event *traits.EnterLeaveEvent, opts ...resource.WriteOption) error
- func (m *Model) GetEnterLeaveEvent(opts ...resource.ReadOption) (*traits.EnterLeaveEvent, error)
- func (m *Model) PullEnterLeaveEvents(ctx context.Context, opts ...resource.ReadOption) <-chan EnterLeaveEventChange
- func (m *Model) ResetTotals() error
- type ModelOption
- type ModelServer
- func (m *ModelServer) GetEnterLeaveEvent(ctx context.Context, request *traits.GetEnterLeaveEventRequest) (*traits.EnterLeaveEvent, error)
- func (m *ModelServer) PullEnterLeaveEvents(request *traits.PullEnterLeaveEventsRequest, ...) error
- func (m *ModelServer) Register(server grpc.ServiceRegistrar)
- func (m *ModelServer) ResetEnterLeaveTotals(ctx context.Context, request *traits.ResetEnterLeaveTotalsRequest) (*traits.ResetEnterLeaveTotalsResponse, error)
- func (m *ModelServer) Unwrap() any
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithInitialEnterLeaveEvent(&traits.EnterLeaveEvent{ EnterTotal: &zero, LeaveTotal: &zero, }), }
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithEnterLeaveEventOption ¶
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.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedEnterLeaveSensorApiServer router.Router }
ApiRouter is a traits.EnterLeaveSensorApiServer that allows routing named requests to specific traits.EnterLeaveSensorApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
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) PullEnterLeaveEvents ¶
func (r *ApiRouter) PullEnterLeaveEvents(request *traits.PullEnterLeaveEventsRequest, server traits.EnterLeaveSensorApi_PullEnterLeaveEventsServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveEnterLeaveSensorApiClient ¶
func (r *ApiRouter) RemoveEnterLeaveSensorApiClient(name string) traits.EnterLeaveSensorApiClient
func (*ApiRouter) ResetEnterLeaveTotals ¶
func (r *ApiRouter) ResetEnterLeaveTotals(ctx context.Context, request *traits.ResetEnterLeaveTotalsRequest) (*traits.ResetEnterLeaveTotalsResponse, error)
type ApiWrapper ¶
type ApiWrapper struct { traits.EnterLeaveSensorApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.EnterLeaveSensorApiServer) *ApiWrapper
WrapApi adapts a traits.EnterLeaveSensorApiServer and presents it as a traits.EnterLeaveSensorApiClient
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.EnterLeaveSensorApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type EnterLeaveEventChange ¶
type EnterLeaveEventChange struct { ChangeTime time.Time Value *traits.EnterLeaveEvent }
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedEnterLeaveSensorInfoServer router.Router }
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.ServiceRegistrar)
func (*InfoRouter) RemoveEnterLeaveSensorInfoClient ¶
func (r *InfoRouter) RemoveEnterLeaveSensorInfoClient(name string) traits.EnterLeaveSensorInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.EnterLeaveSensorInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.EnterLeaveSensorInfoServer) *InfoWrapper
WrapInfo adapts a traits.EnterLeaveSensorInfoServer and presents it as a traits.EnterLeaveSensorInfoClient
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.EnterLeaveSensorInfoServer
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 the data structure for representing an EnterLeaveSensor trait.
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
- No InterceptorBefore option is provided
- The events direction is either ENTER or LEAVE
- 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 ¶
type ModelOption ¶
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) PullEnterLeaveEvents ¶
func (m *ModelServer) PullEnterLeaveEvents(request *traits.PullEnterLeaveEventsRequest, server traits.EnterLeaveSensorApi_PullEnterLeaveEventsServer) error
func (*ModelServer) Register ¶
func (m *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) ResetEnterLeaveTotals ¶
func (m *ModelServer) ResetEnterLeaveTotals(ctx context.Context, request *traits.ResetEnterLeaveTotalsRequest) (*traits.ResetEnterLeaveTotalsResponse, error)
func (*ModelServer) Unwrap ¶
func (m *ModelServer) Unwrap() any