electric

package
v0.0.0-...-8846729 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 25 Imported by: 7

Documentation

Index

Examples

Constants

View Source
const (
	MemorySettingsApi_UpdateDemand_FullMethodName = "/smartcore.go.trait.electric.MemorySettingsApi/UpdateDemand"
	MemorySettingsApi_CreateMode_FullMethodName   = "/smartcore.go.trait.electric.MemorySettingsApi/CreateMode"
	MemorySettingsApi_UpdateMode_FullMethodName   = "/smartcore.go.trait.electric.MemorySettingsApi/UpdateMode"
	MemorySettingsApi_DeleteMode_FullMethodName   = "/smartcore.go.trait.electric.MemorySettingsApi/DeleteMode"
)

Variables

View Source
var (
	ErrModeNotFound     = status.Error(codes.NotFound, "electric mode not found")
	ErrNormalModeExists = status.Error(codes.AlreadyExists, "a normal electric mode already exists")
	ErrDeleteActiveMode = status.Error(codes.FailedPrecondition, "attempt to delete active mode")
)

DefaultModelOptions holds the default options for the model.

View Source
var File_pkg_trait_electric_memory_settings_proto protoreflect.FileDescriptor
View Source
var MemorySettingsApi_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "smartcore.go.trait.electric.MemorySettingsApi",
	HandlerType: (*MemorySettingsApiServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "UpdateDemand",
			Handler:    _MemorySettingsApi_UpdateDemand_Handler,
		},
		{
			MethodName: "CreateMode",
			Handler:    _MemorySettingsApi_CreateMode_Handler,
		},
		{
			MethodName: "UpdateMode",
			Handler:    _MemorySettingsApi_UpdateMode_Handler,
		},
		{
			MethodName: "DeleteMode",
			Handler:    _MemorySettingsApi_DeleteMode_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "pkg/trait/electric/memory_settings.proto",
}

MemorySettingsApi_ServiceDesc is the grpc.ServiceDesc for MemorySettingsApi service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterMemorySettingsApiServer

func RegisterMemorySettingsApiServer(s grpc.ServiceRegistrar, srv MemorySettingsApiServer)

func WithActiveModeOption

func WithActiveModeOption(opts ...resource.Option) resource.Option

WithActiveModeOption configures the activeMode resource of the model.

func WithClock

func WithClock(clock clock.Clock) resource.Option

WithClock returns an option that configures the model to use the given clock for all resources. Overrides resource.WithClock() if used before this option. Combining this with resource.WithClock() is not recommended.

func WithDemandOption

func WithDemandOption(opts ...resource.Option) resource.Option

WithDemandOption configures the demand resource of the model.

func WithElectricApiClientFactory

func WithElectricApiClientFactory(f func(name string) (traits.ElectricApiClient, error)) router.Option

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

func WithElectricInfoClientFactory

func WithElectricInfoClientFactory(f func(name string) (traits.ElectricInfoClient, error)) router.Option

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

func WithInitialActiveMode

func WithInitialActiveMode(activeMode *traits.ElectricMode) resource.Option

WithInitialActiveMode returns an option that configures the model to initialise with the given active mode.

func WithInitialDemand

func WithInitialDemand(demand *traits.ElectricDemand) resource.Option

WithInitialDemand returns an option that configures the model to initialise with the given demand.

func WithInitialMode

func WithInitialMode(mode ...*traits.ElectricMode) resource.Option

WithInitialMode returns an option that configures the model to initialise with the given modes. Can be used multiple times with modes being additive. Creating a model with duplicate mode ids will panic. Calling this function with an empty mode id property will panic.

func WithMemorySettingsApiClientFactory

func WithMemorySettingsApiClientFactory(f func(name string) (MemorySettingsApiClient, error)) router.Option

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

func WithModeOption

func WithModeOption(opts ...resource.Option) resource.Option

WithModeOption configures the mode resource of the model.

func WithRNG

func WithRNG(rng *rand.Rand) resource.Option

WithRNG returns an option that configures the model to use the given random number generator. Overrides resource.WithRNG() if used before this option.

Types

type ApiRouter

ApiRouter is a traits.ElectricApiServer that allows routing named requests to specific traits.ElectricApiClient

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

func (*ApiRouter) AddElectricApiClient

func (r *ApiRouter) AddElectricApiClient(name string, client traits.ElectricApiClient) traits.ElectricApiClient

func (*ApiRouter) ClearActiveMode

func (r *ApiRouter) ClearActiveMode(ctx context.Context, request *traits.ClearActiveModeRequest) (*traits.ElectricMode, error)

func (*ApiRouter) GetActiveMode

func (r *ApiRouter) GetActiveMode(ctx context.Context, request *traits.GetActiveModeRequest) (*traits.ElectricMode, error)

func (*ApiRouter) GetDemand

func (r *ApiRouter) GetDemand(ctx context.Context, request *traits.GetDemandRequest) (*traits.ElectricDemand, error)

func (*ApiRouter) GetElectricApiClient

func (r *ApiRouter) GetElectricApiClient(name string) (traits.ElectricApiClient, error)

func (*ApiRouter) HoldsType

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

func (*ApiRouter) ListModes

func (*ApiRouter) PullActiveMode

func (*ApiRouter) PullDemand

func (*ApiRouter) PullModes

func (*ApiRouter) Register

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

func (*ApiRouter) RemoveElectricApiClient

func (r *ApiRouter) RemoveElectricApiClient(name string) traits.ElectricApiClient

func (*ApiRouter) UpdateActiveMode

func (r *ApiRouter) UpdateActiveMode(ctx context.Context, request *traits.UpdateActiveModeRequest) (*traits.ElectricMode, error)

type ApiWrapper

type ApiWrapper struct {
	traits.ElectricApiClient
	// contains filtered or unexported fields
}

func WrapApi

func WrapApi(server traits.ElectricApiServer) *ApiWrapper

WrapApi adapts a traits.ElectricApiServer and presents it as a traits.ElectricApiClient

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

UnwrapServer returns the underlying server instance.

func (*ApiWrapper) UnwrapService

func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type CreateModeRequest

type CreateModeRequest struct {

	// The name of the device.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The mode to create. ID will be created on the server.
	Mode *traits.ElectricMode `protobuf:"bytes,2,opt,name=mode,proto3" json:"mode,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateModeRequest) Descriptor deprecated

func (*CreateModeRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateModeRequest.ProtoReflect.Descriptor instead.

func (*CreateModeRequest) GetMode

func (x *CreateModeRequest) GetMode() *traits.ElectricMode

func (*CreateModeRequest) GetName

func (x *CreateModeRequest) GetName() string

func (*CreateModeRequest) ProtoMessage

func (*CreateModeRequest) ProtoMessage()

func (*CreateModeRequest) ProtoReflect

func (x *CreateModeRequest) ProtoReflect() protoreflect.Message

func (*CreateModeRequest) Reset

func (x *CreateModeRequest) Reset()

func (*CreateModeRequest) String

func (x *CreateModeRequest) String() string

type DeleteModeRequest

type DeleteModeRequest struct {

	// The name of the device.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The ID of the mode to delete.
	Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// If set to true and the mode is not found the request will succeed but no action will be taken on the server.
	AllowMissing bool `protobuf:"varint,3,opt,name=allow_missing,json=allowMissing,proto3" json:"allow_missing,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteModeRequest) Descriptor deprecated

func (*DeleteModeRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteModeRequest.ProtoReflect.Descriptor instead.

func (*DeleteModeRequest) GetAllowMissing

func (x *DeleteModeRequest) GetAllowMissing() bool

func (*DeleteModeRequest) GetId

func (x *DeleteModeRequest) GetId() string

func (*DeleteModeRequest) GetName

func (x *DeleteModeRequest) GetName() string

func (*DeleteModeRequest) ProtoMessage

func (*DeleteModeRequest) ProtoMessage()

func (*DeleteModeRequest) ProtoReflect

func (x *DeleteModeRequest) ProtoReflect() protoreflect.Message

func (*DeleteModeRequest) Reset

func (x *DeleteModeRequest) Reset()

func (*DeleteModeRequest) String

func (x *DeleteModeRequest) String() string

type InfoRouter

InfoRouter is a traits.ElectricInfoServer that allows routing named requests to specific traits.ElectricInfoClient

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

func (*InfoRouter) AddElectricInfoClient

func (r *InfoRouter) AddElectricInfoClient(name string, client traits.ElectricInfoClient) traits.ElectricInfoClient

func (*InfoRouter) GetElectricInfoClient

func (r *InfoRouter) GetElectricInfoClient(name string) (traits.ElectricInfoClient, error)

func (*InfoRouter) HoldsType

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

func (*InfoRouter) Register

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

func (*InfoRouter) RemoveElectricInfoClient

func (r *InfoRouter) RemoveElectricInfoClient(name string) traits.ElectricInfoClient

type InfoWrapper

type InfoWrapper struct {
	traits.ElectricInfoClient
	// contains filtered or unexported fields
}

func WrapInfo

func WrapInfo(server traits.ElectricInfoServer) *InfoWrapper

WrapInfo adapts a traits.ElectricInfoServer and presents it as a traits.ElectricInfoClient

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

UnwrapServer returns the underlying server instance.

func (*InfoWrapper) UnwrapService

func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type MemorySettingsApiClient

type MemorySettingsApiClient interface {
	UpdateDemand(ctx context.Context, in *UpdateDemandRequest, opts ...grpc.CallOption) (*traits.ElectricDemand, error)
	// Create a new mode in the device.
	// Do not specify the id, this will be provided by the server.
	// This will not validate that exactly one normal mode exists,
	// the ClearActiveMode method will choose the first normal mode found.
	CreateMode(ctx context.Context, in *CreateModeRequest, opts ...grpc.CallOption) (*traits.ElectricMode, error)
	UpdateMode(ctx context.Context, in *UpdateModeRequest, opts ...grpc.CallOption) (*traits.ElectricMode, error)
	// Delete an existing mode.
	// Returns NOT_FOUND if the mode, identified by id, is not found. See allow_missing.
	DeleteMode(ctx context.Context, in *DeleteModeRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}

MemorySettingsApiClient is the client API for MemorySettingsApi service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

MemorySettingsApi allows a client to adjust the internal state of an in-memory electric device. Use for configuring testing.

type MemorySettingsApiRouter

type MemorySettingsApiRouter struct {
	UnimplementedMemorySettingsApiServer

	router.Router
}

MemorySettingsApiRouter is a MemorySettingsApiServer that allows routing named requests to specific MemorySettingsApiClient

func NewMemorySettingsApiRouter

func NewMemorySettingsApiRouter(opts ...router.Option) *MemorySettingsApiRouter

func (*MemorySettingsApiRouter) Add

func (r *MemorySettingsApiRouter) Add(name string, client any) any

Add extends Router.Add to panic if client is not of type MemorySettingsApiClient.

func (*MemorySettingsApiRouter) AddMemorySettingsApiClient

func (r *MemorySettingsApiRouter) AddMemorySettingsApiClient(name string, client MemorySettingsApiClient) MemorySettingsApiClient

func (*MemorySettingsApiRouter) CreateMode

func (*MemorySettingsApiRouter) DeleteMode

func (r *MemorySettingsApiRouter) DeleteMode(ctx context.Context, request *DeleteModeRequest) (*emptypb.Empty, error)

func (*MemorySettingsApiRouter) GetMemorySettingsApiClient

func (r *MemorySettingsApiRouter) GetMemorySettingsApiClient(name string) (MemorySettingsApiClient, error)

func (*MemorySettingsApiRouter) HoldsType

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

func (*MemorySettingsApiRouter) Register

func (r *MemorySettingsApiRouter) Register(server grpc.ServiceRegistrar)

func (*MemorySettingsApiRouter) RemoveMemorySettingsApiClient

func (r *MemorySettingsApiRouter) RemoveMemorySettingsApiClient(name string) MemorySettingsApiClient

func (*MemorySettingsApiRouter) UpdateDemand

func (*MemorySettingsApiRouter) UpdateMode

type MemorySettingsApiServer

type MemorySettingsApiServer interface {
	UpdateDemand(context.Context, *UpdateDemandRequest) (*traits.ElectricDemand, error)
	// Create a new mode in the device.
	// Do not specify the id, this will be provided by the server.
	// This will not validate that exactly one normal mode exists,
	// the ClearActiveMode method will choose the first normal mode found.
	CreateMode(context.Context, *CreateModeRequest) (*traits.ElectricMode, error)
	UpdateMode(context.Context, *UpdateModeRequest) (*traits.ElectricMode, error)
	// Delete an existing mode.
	// Returns NOT_FOUND if the mode, identified by id, is not found. See allow_missing.
	DeleteMode(context.Context, *DeleteModeRequest) (*emptypb.Empty, error)
	// contains filtered or unexported methods
}

MemorySettingsApiServer is the server API for MemorySettingsApi service. All implementations must embed UnimplementedMemorySettingsApiServer for forward compatibility.

MemorySettingsApi allows a client to adjust the internal state of an in-memory electric device. Use for configuring testing.

type MemorySettingsApiWrapper

type MemorySettingsApiWrapper struct {
	MemorySettingsApiClient
	// contains filtered or unexported fields
}

func WrapMemorySettingsApi

func WrapMemorySettingsApi(server MemorySettingsApiServer) *MemorySettingsApiWrapper

WrapMemorySettingsApi adapts a MemorySettingsApiServer and presents it as a MemorySettingsApiClient

func (*MemorySettingsApiWrapper) Unwrap

func (w *MemorySettingsApiWrapper) Unwrap() any

Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.

func (*MemorySettingsApiWrapper) UnwrapServer

UnwrapServer returns the underlying server instance.

func (*MemorySettingsApiWrapper) UnwrapService

type Model

type Model struct {
	Rng *rand.Rand // for generating mode ids
	// contains filtered or unexported fields
}

Model is a simple data store for electric devices. It simply stores the data given to it, and does not implement any business logic. For the implementation of the gRPC trait based on Model, see ModelServer. Invariants:

  1. At most one mode has normal = true.
  2. The active mode cannot be deleted.
  3. Only a mode that exists can be active (except when the Model is first created, when a dummy mode is active)

func NewModel

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

NewModel constructs a Model with default values:

Current: 0
Voltage: 240
Rating: 13

No modes, active mode is empty.

func (*Model) ActiveMode

func (m *Model) ActiveMode(opts ...resource.ReadOption) *traits.ElectricMode

ActiveMode returns the electric mode that is currently active on this device. When the Model is first created, its active mode is a dummy mode with all-blank fields. After it is changed for the first time, it will always correspond to one of the modes that can be listed by Modes. The StartTime fields will reflect when the mode became active. The fields returned can be filtered using resource.WithReadMask

func (*Model) AddMode

func (m *Model) AddMode(mode *traits.ElectricMode) error

AddMode adds a new mode to the device using the modes Id. The Id field on the mode must be set. If mode has Normal == true, and the device already has a normal mode, then ErrNormalModeExists will result.

func (*Model) ChangeActiveMode

func (m *Model) ChangeActiveMode(id string) (*traits.ElectricMode, error)

ChangeActiveMode will switch the active mode to a previously-defined mode with the given ID. Attempting to change to a mode ID that does not exist on this device will result in an error. Updates the StartTime of the mode to the current time if the mode changes.

func (*Model) ChangeToNormalMode

func (m *Model) ChangeToNormalMode() (*traits.ElectricMode, error)

ChangeToNormalMode will (atomically) look up the device's normal mode (mode with Normal == true) and change to that mode. If this device does not have a normal mode, ErrModeNotFound is returned. Updates the StartTime of the mode to the current time if the mode changes.

func (*Model) CreateMode

func (m *Model) CreateMode(mode *traits.ElectricMode) (*traits.ElectricMode, error)

CreateMode adds a new mode to the device. The Id field on the mode must not be set, as the Id will be allocated by the device. If mode has Normal == true, and the device already has a normal mode, then ErrNormalModeExists will result. Returns the newly created mode, including its Id.

func (*Model) DeleteMode

func (m *Model) DeleteMode(id string, opts ...resource.WriteOption) error

DeleteMode will remove the mode with the given Id from the device. If the mode does not exist, then ErrModeNotFound is returned. If the mode specified is the active mode, then ErrDeleteActiveMode is returned and the mode is not deleted. Otherwise, the operation succeeded and nil is returned.

func (*Model) Demand

func (m *Model) Demand(opts ...resource.ReadOption) *traits.ElectricDemand

Demand gets the demand stored in this Model. The fields returned can be filtered by passing resource.WithReadMask.

func (*Model) FindMode

func (m *Model) FindMode(id string) (mode *traits.ElectricMode, ok bool)

FindMode will attempt to retrieve the mode with the given ID. If the mode was found, it is returned with ok == true. Otherwise, the returned mode is unspecified and ok == false.

func (*Model) Modes

func (m *Model) Modes(opts ...resource.ReadOption) []*traits.ElectricMode

Modes returns a list of all registered modes, sorted by their ID.

func (*Model) NormalMode

func (m *Model) NormalMode() (*traits.ElectricMode, bool)

NormalMode returns the mode which has Normal == true. A device can have at most 1 such mode. If there is no normal mode on this device, then (nil, false) is returned.

func (*Model) PullActiveMode

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

PullActiveMode subscribes to changes to the active mode. Whenever the active mode is changed (for example, by calling ChangeActiveMode), the channel will send a notification. The returned channel will be closed when done is called. You must call done after you are finished with the channel to prevents leaks and/or deadlocks. The channel will also be closed if ctx is cancelled.

func (*Model) PullDemand

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

PullDemand subscribes to changes to the electricity demand on this device. The returned channel will be closed when done is called. You must call done after you are finished with the channel to prevents leaks and/or deadlocks. The channel will also be closed if ctx is cancelled.

func (*Model) PullModes

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

PullModes subscribes to changes to modes. Creation, modification or deletion of a mode on this device will send a PullModesChange describing the event down the changes channel. The returned channel will be closed when done is called. You must call done after you are finished with the channel to prevents leaks and/or deadlocks. The channel will also be closed if ctx is cancelled.

func (*Model) SetActiveMode

func (m *Model) SetActiveMode(mode *traits.ElectricMode) error

SetActiveMode updates the active mode to the one specified. The mode.Id should exist in the known Modes of this model or an error will be returned. The mode.StartTime will not be set for you.

func (*Model) UpdateDemand

func (m *Model) UpdateDemand(update *traits.ElectricDemand, opts ...resource.WriteOption) (*traits.ElectricDemand, error)

UpdateDemand will update the stored traits.ElectricDemand associated with this device. The fields to update can be filtered by passing resource.WithUpdateMask. The updated traits.ElectricDemand is returned.

func (*Model) UpdateMode

func (m *Model) UpdateMode(mode *traits.ElectricMode, opts ...resource.WriteOption) (*traits.ElectricMode, error)

UpdateMode will modify one of the modes stored in this device. The mode to be modified is specified by mode.Id, which must be set. Fields to be modified can be selected using mask - to modify all fields, pass a nil mask.

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

ModelServer is an implementation of ElectricApiServer and MemorySettingsApiServer backed by a Model.

Example
mem := NewModel()
device := NewModelServer(mem)

client := WrapApi(device)
settings := WrapMemorySettingsApi(device)

ctx := context.Background()
_, err := settings.CreateMode(ctx, &CreateModeRequest{
	Name: "foo",
	Mode: &traits.ElectricMode{
		Title:       "Normal mode",
		Description: "Normal mode",
		Segments: []*traits.ElectricMode_Segment{
			{Magnitude: 1},
		},
		Normal: true,
	},
})
if err != nil {
	log.Println("create mode failed:", err)
	return
}

_, err = client.ClearActiveMode(ctx, &traits.ClearActiveModeRequest{
	Name: "foo",
})
if err != nil {
	log.Println("clear mode failed:", err)
}

mode, err := client.GetActiveMode(ctx, &traits.GetActiveModeRequest{Name: "foo"})
if err != nil {
	log.Println("GetActiveMode failed:", err)
	return
}
fmt.Println(mode.Title)
Output:

Normal mode

func NewModelServer

func NewModelServer(model *Model) *ModelServer

func (*ModelServer) ClearActiveMode

func (*ModelServer) CreateMode

func (s *ModelServer) CreateMode(_ context.Context, request *CreateModeRequest) (*traits.ElectricMode, error)

func (*ModelServer) DeleteMode

func (s *ModelServer) DeleteMode(_ context.Context, request *DeleteModeRequest) (*emptypb.Empty, error)

func (*ModelServer) GetActiveMode

func (s *ModelServer) GetActiveMode(_ context.Context, request *traits.GetActiveModeRequest) (*traits.ElectricMode, error)

func (*ModelServer) GetDemand

func (*ModelServer) ListModes

func (*ModelServer) PullActiveMode

func (*ModelServer) PullDemand

func (*ModelServer) PullModes

func (*ModelServer) Register

func (s *ModelServer) Register(server grpc.ServiceRegistrar)

func (*ModelServer) Unwrap

func (s *ModelServer) Unwrap() any

func (*ModelServer) UpdateActiveMode

func (s *ModelServer) UpdateActiveMode(_ context.Context, request *traits.UpdateActiveModeRequest) (*traits.ElectricMode, error)

func (*ModelServer) UpdateDemand

func (s *ModelServer) UpdateDemand(_ context.Context, request *UpdateDemandRequest) (*traits.ElectricDemand, error)

func (*ModelServer) UpdateMode

func (s *ModelServer) UpdateMode(_ context.Context, request *UpdateModeRequest) (*traits.ElectricMode, error)

type PullActiveModeChange

type PullActiveModeChange struct {
	ActiveMode *traits.ElectricMode
	ChangeTime time.Time
}

type PullDemandChange

type PullDemandChange struct {
	Value      *traits.ElectricDemand
	ChangeTime time.Time
}

type PullModesChange

type PullModesChange struct {
	Type       types.ChangeType
	NewValue   *traits.ElectricMode
	OldValue   *traits.ElectricMode
	ChangeTime time.Time
}

type UnimplementedMemorySettingsApiServer

type UnimplementedMemorySettingsApiServer struct{}

UnimplementedMemorySettingsApiServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedMemorySettingsApiServer) CreateMode

func (UnimplementedMemorySettingsApiServer) DeleteMode

func (UnimplementedMemorySettingsApiServer) UpdateDemand

func (UnimplementedMemorySettingsApiServer) UpdateMode

type UnsafeMemorySettingsApiServer

type UnsafeMemorySettingsApiServer interface {
	// contains filtered or unexported methods
}

UnsafeMemorySettingsApiServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MemorySettingsApiServer will result in compilation errors.

type UpdateDemandRequest

type UpdateDemandRequest struct {

	// The name of the device.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Updated properties of the device.
	Demand *traits.ElectricDemand `protobuf:"bytes,2,opt,name=demand,proto3" json:"demand,omitempty"`
	// Fields that should be updated.
	UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,3,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateDemandRequest) Descriptor deprecated

func (*UpdateDemandRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateDemandRequest.ProtoReflect.Descriptor instead.

func (*UpdateDemandRequest) GetDemand

func (x *UpdateDemandRequest) GetDemand() *traits.ElectricDemand

func (*UpdateDemandRequest) GetName

func (x *UpdateDemandRequest) GetName() string

func (*UpdateDemandRequest) GetUpdateMask

func (x *UpdateDemandRequest) GetUpdateMask() *fieldmaskpb.FieldMask

func (*UpdateDemandRequest) ProtoMessage

func (*UpdateDemandRequest) ProtoMessage()

func (*UpdateDemandRequest) ProtoReflect

func (x *UpdateDemandRequest) ProtoReflect() protoreflect.Message

func (*UpdateDemandRequest) Reset

func (x *UpdateDemandRequest) Reset()

func (*UpdateDemandRequest) String

func (x *UpdateDemandRequest) String() string

type UpdateModeRequest

type UpdateModeRequest struct {

	// The name of the device.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The mode to create.
	// The ID should match an existing mode or NOT_FOUND will be returned.
	Mode *traits.ElectricMode `protobuf:"bytes,2,opt,name=mode,proto3" json:"mode,omitempty"`
	// The fields to update.
	// If absent all fields will be updated.
	UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,3,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateModeRequest) Descriptor deprecated

func (*UpdateModeRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateModeRequest.ProtoReflect.Descriptor instead.

func (*UpdateModeRequest) GetMode

func (x *UpdateModeRequest) GetMode() *traits.ElectricMode

func (*UpdateModeRequest) GetName

func (x *UpdateModeRequest) GetName() string

func (*UpdateModeRequest) GetUpdateMask

func (x *UpdateModeRequest) GetUpdateMask() *fieldmaskpb.FieldMask

func (*UpdateModeRequest) ProtoMessage

func (*UpdateModeRequest) ProtoMessage()

func (*UpdateModeRequest) ProtoReflect

func (x *UpdateModeRequest) ProtoReflect() protoreflect.Message

func (*UpdateModeRequest) Reset

func (x *UpdateModeRequest) Reset()

func (*UpdateModeRequest) String

func (x *UpdateModeRequest) String() string

Directories

Path Synopsis
Package modepb contains utilities for working with traits.ElectricMode values.
Package modepb contains utilities for working with traits.ElectricMode values.
Package segmentpb contains utilities for working with traits.ElectricMode_Segment values.
Package segmentpb contains utilities for working with traits.ElectricMode_Segment values.

Jump to

Keyboard shortcuts

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