Documentation ¶
Index ¶
- Variables
- func WithEnergyLevelOption(opts ...resource.Option) resource.Option
- func WithEnergyStorageApiClientFactory(f func(name string) (traits.EnergyStorageApiClient, error)) router.Option
- func WithEnergyStorageInfoClientFactory(f func(name string) (traits.EnergyStorageInfoClient, error)) router.Option
- func WithInitialEnergyLevel(energyLevel *traits.EnergyLevel) resource.Option
- type ApiRouter
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddEnergyStorageApiClient(name string, client traits.EnergyStorageApiClient) traits.EnergyStorageApiClient
- func (r *ApiRouter) Charge(ctx context.Context, request *traits.ChargeRequest) (*traits.ChargeResponse, error)
- func (r *ApiRouter) GetEnergyLevel(ctx context.Context, request *traits.GetEnergyLevelRequest) (*traits.EnergyLevel, error)
- func (r *ApiRouter) GetEnergyStorageApiClient(name string) (traits.EnergyStorageApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) PullEnergyLevel(request *traits.PullEnergyLevelRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemoveEnergyStorageApiClient(name string) traits.EnergyStorageApiClient
- type ApiWrapper
- type InfoRouter
- func (r *InfoRouter) Add(name string, client any) any
- func (r *InfoRouter) AddEnergyStorageInfoClient(name string, client traits.EnergyStorageInfoClient) traits.EnergyStorageInfoClient
- func (r *InfoRouter) DescribeEnergyLevel(ctx context.Context, request *traits.DescribeEnergyLevelRequest) (*traits.EnergyLevelSupport, error)
- func (r *InfoRouter) GetEnergyStorageInfoClient(name string) (traits.EnergyStorageInfoClient, error)
- func (r *InfoRouter) HoldsType(client any) bool
- func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
- func (r *InfoRouter) RemoveEnergyStorageInfoClient(name string) traits.EnergyStorageInfoClient
- type InfoWrapper
- type Model
- func (m *Model) GetEnergyLevel(opts ...resource.ReadOption) (*traits.EnergyLevel, error)
- func (m *Model) PullEnergyLevel(ctx context.Context, opts ...resource.ReadOption) <-chan PullEnergyLevelChange
- func (m *Model) UpdateEnergyLevel(energyLevel *traits.EnergyLevel, opts ...resource.WriteOption) (*traits.EnergyLevel, error)
- type ModelOption
- type ModelServer
- func (s *ModelServer) Charge(_ context.Context, request *traits.ChargeRequest) (*traits.ChargeResponse, error)
- func (s *ModelServer) GetEnergyLevel(_ context.Context, request *traits.GetEnergyLevelRequest) (*traits.EnergyLevel, error)
- func (s *ModelServer) PullEnergyLevel(request *traits.PullEnergyLevelRequest, ...) error
- func (s *ModelServer) Register(server grpc.ServiceRegistrar)
- func (s *ModelServer) Unwrap() any
- type PullEnergyLevelChange
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions = []resource.Option{ WithInitialEnergyLevel(&traits.EnergyLevel{}), WithEnergyLevelOption(resource.WithMessageEquivalence(cmp.Equal( cmp.FloatValueApprox(0, 0.1), cmp.TimeValueWithin(1*time.Second), cmp.DurationValueWithin(1*time.Second), ))), }
DefaultModelOptions holds the default options for the model.
Functions ¶
func WithEnergyLevelOption ¶
WithEnergyLevelOption configures the energyLevel resource of the model.
func WithEnergyStorageApiClientFactory ¶
func WithEnergyStorageApiClientFactory(f func(name string) (traits.EnergyStorageApiClient, error)) router.Option
WithEnergyStorageApiClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithEnergyStorageInfoClientFactory ¶
func WithEnergyStorageInfoClientFactory(f func(name string) (traits.EnergyStorageInfoClient, error)) router.Option
WithEnergyStorageInfoClientFactory instructs the router to create a new client the first time Get is called for that name.
func WithInitialEnergyLevel ¶
func WithInitialEnergyLevel(energyLevel *traits.EnergyLevel) resource.Option
WithInitialEnergyLevel returns an option that configures the model to initialise with the given energy level.
Types ¶
type ApiRouter ¶
type ApiRouter struct { traits.UnimplementedEnergyStorageApiServer router.Router }
ApiRouter is a traits.EnergyStorageApiServer that allows routing named requests to specific traits.EnergyStorageApiClient
func NewApiRouter ¶
func (*ApiRouter) Add ¶
Add extends Router.Add to panic if client is not of type traits.EnergyStorageApiClient.
func (*ApiRouter) AddEnergyStorageApiClient ¶
func (r *ApiRouter) AddEnergyStorageApiClient(name string, client traits.EnergyStorageApiClient) traits.EnergyStorageApiClient
func (*ApiRouter) Charge ¶
func (r *ApiRouter) Charge(ctx context.Context, request *traits.ChargeRequest) (*traits.ChargeResponse, error)
func (*ApiRouter) GetEnergyLevel ¶
func (r *ApiRouter) GetEnergyLevel(ctx context.Context, request *traits.GetEnergyLevelRequest) (*traits.EnergyLevel, error)
func (*ApiRouter) GetEnergyStorageApiClient ¶
func (r *ApiRouter) GetEnergyStorageApiClient(name string) (traits.EnergyStorageApiClient, error)
func (*ApiRouter) PullEnergyLevel ¶
func (r *ApiRouter) PullEnergyLevel(request *traits.PullEnergyLevelRequest, server traits.EnergyStorageApi_PullEnergyLevelServer) error
func (*ApiRouter) Register ¶
func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
func (*ApiRouter) RemoveEnergyStorageApiClient ¶
func (r *ApiRouter) RemoveEnergyStorageApiClient(name string) traits.EnergyStorageApiClient
type ApiWrapper ¶
type ApiWrapper struct { traits.EnergyStorageApiClient // contains filtered or unexported fields }
func WrapApi ¶
func WrapApi(server traits.EnergyStorageApiServer) *ApiWrapper
WrapApi adapts a traits.EnergyStorageApiServer and presents it as a traits.EnergyStorageApiClient
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.EnergyStorageApiServer
UnwrapServer returns the underlying server instance.
func (*ApiWrapper) UnwrapService ¶
func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)
type InfoRouter ¶
type InfoRouter struct { traits.UnimplementedEnergyStorageInfoServer router.Router }
InfoRouter is a traits.EnergyStorageInfoServer that allows routing named requests to specific traits.EnergyStorageInfoClient
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.EnergyStorageInfoClient.
func (*InfoRouter) AddEnergyStorageInfoClient ¶
func (r *InfoRouter) AddEnergyStorageInfoClient(name string, client traits.EnergyStorageInfoClient) traits.EnergyStorageInfoClient
func (*InfoRouter) DescribeEnergyLevel ¶
func (r *InfoRouter) DescribeEnergyLevel(ctx context.Context, request *traits.DescribeEnergyLevelRequest) (*traits.EnergyLevelSupport, error)
func (*InfoRouter) GetEnergyStorageInfoClient ¶
func (r *InfoRouter) GetEnergyStorageInfoClient(name string) (traits.EnergyStorageInfoClient, error)
func (*InfoRouter) HoldsType ¶
func (r *InfoRouter) HoldsType(client any) bool
func (*InfoRouter) Register ¶
func (r *InfoRouter) Register(server grpc.ServiceRegistrar)
func (*InfoRouter) RemoveEnergyStorageInfoClient ¶
func (r *InfoRouter) RemoveEnergyStorageInfoClient(name string) traits.EnergyStorageInfoClient
type InfoWrapper ¶
type InfoWrapper struct { traits.EnergyStorageInfoClient // contains filtered or unexported fields }
func WrapInfo ¶
func WrapInfo(server traits.EnergyStorageInfoServer) *InfoWrapper
WrapInfo adapts a traits.EnergyStorageInfoServer and presents it as a traits.EnergyStorageInfoClient
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.EnergyStorageInfoServer
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 (*Model) GetEnergyLevel ¶
func (m *Model) GetEnergyLevel(opts ...resource.ReadOption) (*traits.EnergyLevel, error)
func (*Model) PullEnergyLevel ¶
func (m *Model) PullEnergyLevel(ctx context.Context, opts ...resource.ReadOption) <-chan PullEnergyLevelChange
func (*Model) UpdateEnergyLevel ¶
func (m *Model) UpdateEnergyLevel(energyLevel *traits.EnergyLevel, opts ...resource.WriteOption) (*traits.EnergyLevel, error)
type ModelOption ¶
ModelOption defined the base type for all options that apply to this traits model.
type ModelServer ¶
type ModelServer struct { traits.UnimplementedEnergyStorageApiServer // contains filtered or unexported fields }
func NewModelServer ¶
func NewModelServer(model *Model, opts ...ServerOption) *ModelServer
func (*ModelServer) Charge ¶
func (s *ModelServer) Charge(_ context.Context, request *traits.ChargeRequest) (*traits.ChargeResponse, error)
func (*ModelServer) GetEnergyLevel ¶
func (s *ModelServer) GetEnergyLevel(_ context.Context, request *traits.GetEnergyLevelRequest) (*traits.EnergyLevel, error)
func (*ModelServer) PullEnergyLevel ¶
func (s *ModelServer) PullEnergyLevel(request *traits.PullEnergyLevelRequest, server traits.EnergyStorageApi_PullEnergyLevelServer) error
func (*ModelServer) Register ¶
func (s *ModelServer) Register(server grpc.ServiceRegistrar)
func (*ModelServer) Unwrap ¶
func (s *ModelServer) Unwrap() any
type PullEnergyLevelChange ¶
type PullEnergyLevelChange struct { Value *traits.EnergyLevel ChangeTime time.Time }
type ServerOption ¶
type ServerOption func(s *ModelServer)
func ReadOnly ¶
func ReadOnly() ServerOption