energystorage

package
v0.0.0-...-97303ad Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

DefaultModelOptions holds the default options for the model.

Functions

func WithEnergyLevelOption

func WithEnergyLevelOption(opts ...resource.Option) resource.Option

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

ApiRouter is a traits.EnergyStorageApiServer that allows routing named requests to specific traits.EnergyStorageApiClient

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

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

func (*ApiRouter) PullEnergyLevel

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

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 NewModel

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

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

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.UnimplementedEnergyStorageApiServer
	// contains filtered or unexported fields
}

func NewModelServer

func NewModelServer(model *Model, opts ...ServerOption) *ModelServer

func (*ModelServer) Charge

func (*ModelServer) GetEnergyLevel

func (s *ModelServer) GetEnergyLevel(_ context.Context, request *traits.GetEnergyLevelRequest) (*traits.EnergyLevel, error)

func (*ModelServer) PullEnergyLevel

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

Jump to

Keyboard shortcuts

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