energystorage

package
v0.0.0-...-fb4a7ab Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 13 Imported by: 0

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.

func WrapApi

WrapApi adapts a traits.EnergyStorageApiServer and presents it as a traits.EnergyStorageApiClient

func WrapInfo

WrapInfo adapts a traits.EnergyStorageInfoServer and presents it as a traits.EnergyStorageInfoClient

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

func (*ApiRouter) RemoveEnergyStorageApiClient

func (r *ApiRouter) RemoveEnergyStorageApiClient(name string) traits.EnergyStorageApiClient

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

func (*InfoRouter) RemoveEnergyStorageInfoClient

func (r *InfoRouter) RemoveEnergyStorageInfoClient(name string) traits.EnergyStorageInfoClient

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

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