resource_state

package
v0.51.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStateAtomStoreID = "ui-state"

DefaultStateAtomStoreID is the default store ID for the global state atom.

View Source
const SRPCStateAtomResourceServiceServiceID = "resource.state.StateAtomResourceService"

Variables

This section is empty.

Functions

func NewSRPCStateAtomResourceServiceHandler

func NewSRPCStateAtomResourceServiceHandler(impl SRPCStateAtomResourceServiceServer, serviceID string) srpc.Handler

NewSRPCStateAtomResourceServiceHandler constructs a new RPC handler. serviceID: if empty, uses default: resource.state.StateAtomResourceService

func SRPCRegisterStateAtomResourceService

func SRPCRegisterStateAtomResourceService(mux srpc.Mux, impl SRPCStateAtomResourceServiceServer) error

SRPCRegisterStateAtomResourceService registers the implementation with the mux. Uses the default serviceID: resource.state.StateAtomResourceService

Types

type GetStateRequest

type GetStateRequest struct {
	// contains filtered or unexported fields
}

GetStateRequest is the request for GetState.

func (*GetStateRequest) CloneMessageVT

func (m *GetStateRequest) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*GetStateRequest) CloneVT

func (m *GetStateRequest) CloneVT() *GetStateRequest

func (*GetStateRequest) EqualMessageVT

func (this *GetStateRequest) EqualMessageVT(thatMsg any) bool

func (*GetStateRequest) EqualVT

func (this *GetStateRequest) EqualVT(that *GetStateRequest) bool

func (*GetStateRequest) MarshalJSON

func (x *GetStateRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshals the GetStateRequest to JSON.

func (*GetStateRequest) MarshalProtoJSON

func (x *GetStateRequest) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the GetStateRequest message to JSON.

func (*GetStateRequest) MarshalProtoText

func (x *GetStateRequest) MarshalProtoText() string

func (*GetStateRequest) MarshalToSizedBufferVT

func (m *GetStateRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*GetStateRequest) MarshalToVT

func (m *GetStateRequest) MarshalToVT(dAtA []byte) (int, error)

func (*GetStateRequest) MarshalVT

func (m *GetStateRequest) MarshalVT() (dAtA []byte, err error)

func (*GetStateRequest) ProtoMessage

func (*GetStateRequest) ProtoMessage()

func (*GetStateRequest) Reset

func (x *GetStateRequest) Reset()

func (*GetStateRequest) SizeVT

func (m *GetStateRequest) SizeVT() (n int)

func (*GetStateRequest) String

func (x *GetStateRequest) String() string

func (*GetStateRequest) UnmarshalJSON

func (x *GetStateRequest) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the GetStateRequest from JSON.

func (*GetStateRequest) UnmarshalProtoJSON

func (x *GetStateRequest) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the GetStateRequest message from JSON.

func (*GetStateRequest) UnmarshalVT

func (m *GetStateRequest) UnmarshalVT(dAtA []byte) error

type GetStateResponse

type GetStateResponse struct {

	// StateJson is the current state as a JSON string.
	StateJson string `protobuf:"bytes,1,opt,name=state_json,json=stateJson,proto3" json:"stateJson,omitempty"`
	// Seqno is the sequence number of this state version.
	Seqno uint64 `protobuf:"varint,2,opt,name=seqno,proto3" json:"seqno,omitempty"`
	// contains filtered or unexported fields
}

GetStateResponse is the response for GetState.

func (*GetStateResponse) CloneMessageVT

func (m *GetStateResponse) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*GetStateResponse) CloneVT

func (m *GetStateResponse) CloneVT() *GetStateResponse

func (*GetStateResponse) EqualMessageVT

func (this *GetStateResponse) EqualMessageVT(thatMsg any) bool

func (*GetStateResponse) EqualVT

func (this *GetStateResponse) EqualVT(that *GetStateResponse) bool

func (*GetStateResponse) GetSeqno

func (x *GetStateResponse) GetSeqno() uint64

func (*GetStateResponse) GetStateJson

func (x *GetStateResponse) GetStateJson() string

func (*GetStateResponse) MarshalJSON

func (x *GetStateResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshals the GetStateResponse to JSON.

func (*GetStateResponse) MarshalProtoJSON

func (x *GetStateResponse) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the GetStateResponse message to JSON.

func (*GetStateResponse) MarshalProtoText

func (x *GetStateResponse) MarshalProtoText() string

func (*GetStateResponse) MarshalToSizedBufferVT

func (m *GetStateResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*GetStateResponse) MarshalToVT

func (m *GetStateResponse) MarshalToVT(dAtA []byte) (int, error)

func (*GetStateResponse) MarshalVT

func (m *GetStateResponse) MarshalVT() (dAtA []byte, err error)

func (*GetStateResponse) ProtoMessage

func (*GetStateResponse) ProtoMessage()

func (*GetStateResponse) Reset

func (x *GetStateResponse) Reset()

func (*GetStateResponse) SizeVT

func (m *GetStateResponse) SizeVT() (n int)

func (*GetStateResponse) String

func (x *GetStateResponse) String() string

func (*GetStateResponse) UnmarshalJSON

func (x *GetStateResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the GetStateResponse from JSON.

func (*GetStateResponse) UnmarshalProtoJSON

func (x *GetStateResponse) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the GetStateResponse message from JSON.

func (*GetStateResponse) UnmarshalVT

func (m *GetStateResponse) UnmarshalVT(dAtA []byte) error

type ObjectStoreStateAtom

type ObjectStoreStateAtom struct {
	// contains filtered or unexported fields
}

ObjectStoreStateAtom implements StateAtomStore using an ObjectStore.

func NewObjectStoreStateAtom

func NewObjectStoreStateAtom(
	storeID string,
	objStore object.ObjectStore,
) *ObjectStoreStateAtom

NewObjectStoreStateAtom creates a new ObjectStore-backed state atom.

func (*ObjectStoreStateAtom) Get

Get returns the current state JSON and sequence number.

func (*ObjectStoreStateAtom) GetStoreID

func (s *ObjectStoreStateAtom) GetStoreID() string

GetStoreID returns the store ID.

func (*ObjectStoreStateAtom) Set

func (s *ObjectStoreStateAtom) Set(ctx context.Context, stateJson string) (uint64, error)

Set updates the state JSON and returns the new sequence number.

func (*ObjectStoreStateAtom) WaitSeqno

func (s *ObjectStoreStateAtom) WaitSeqno(ctx context.Context, minSeqno uint64) (uint64, error)

WaitSeqno blocks until the seqno is >= the given value.

type SRPCStateAtomResourceServiceClient

type SRPCStateAtomResourceServiceClient interface {
	// SRPCClient returns the underlying SRPC client.
	SRPCClient() srpc.Client

	// GetState returns the current state value.
	GetState(ctx context.Context, in *GetStateRequest) (*GetStateResponse, error)
	// SetState updates the state value.
	SetState(ctx context.Context, in *SetStateRequest) (*SetStateResponse, error)
	// WatchState watches for state changes.
	// Streams the current state immediately, then any updates.
	WatchState(ctx context.Context, in *WatchStateRequest) (SRPCStateAtomResourceService_WatchStateClient, error)
}

func NewSRPCStateAtomResourceServiceClient

func NewSRPCStateAtomResourceServiceClient(cc srpc.Client) SRPCStateAtomResourceServiceClient

func NewSRPCStateAtomResourceServiceClientWithServiceID

func NewSRPCStateAtomResourceServiceClientWithServiceID(cc srpc.Client, serviceID string) SRPCStateAtomResourceServiceClient

type SRPCStateAtomResourceServiceHandler

type SRPCStateAtomResourceServiceHandler struct {
	// contains filtered or unexported fields
}

func (SRPCStateAtomResourceServiceHandler) GetMethodIDs

func (*SRPCStateAtomResourceServiceHandler) GetServiceID

func (d *SRPCStateAtomResourceServiceHandler) GetServiceID() string

func (*SRPCStateAtomResourceServiceHandler) InvokeMethod

func (d *SRPCStateAtomResourceServiceHandler) InvokeMethod(
	serviceID, methodID string,
	strm srpc.Stream,
) (bool, error)

func (SRPCStateAtomResourceServiceHandler) InvokeMethod_GetState

func (SRPCStateAtomResourceServiceHandler) InvokeMethod_SetState

func (SRPCStateAtomResourceServiceHandler) InvokeMethod_WatchState

type SRPCStateAtomResourceServiceServer

type SRPCStateAtomResourceServiceServer interface {
	// GetState returns the current state value.
	GetState(context.Context, *GetStateRequest) (*GetStateResponse, error)
	// SetState updates the state value.
	SetState(context.Context, *SetStateRequest) (*SetStateResponse, error)
	// WatchState watches for state changes.
	// Streams the current state immediately, then any updates.
	WatchState(*WatchStateRequest, SRPCStateAtomResourceService_WatchStateStream) error
}

type SRPCStateAtomResourceService_GetStateStream

type SRPCStateAtomResourceService_GetStateStream interface {
	srpc.Stream
}

type SRPCStateAtomResourceService_SetStateStream

type SRPCStateAtomResourceService_SetStateStream interface {
	srpc.Stream
}

type SRPCStateAtomResourceService_WatchStateClient

type SRPCStateAtomResourceService_WatchStateClient interface {
	srpc.Stream
	Recv() (*WatchStateResponse, error)
	RecvTo(*WatchStateResponse) error
}

type SRPCStateAtomResourceService_WatchStateStream

type SRPCStateAtomResourceService_WatchStateStream interface {
	srpc.Stream
	Send(*WatchStateResponse) error
	SendAndClose(*WatchStateResponse) error
}

type SetStateRequest

type SetStateRequest struct {

	// StateJson is the new state value as a JSON string.
	StateJson string `protobuf:"bytes,1,opt,name=state_json,json=stateJson,proto3" json:"stateJson,omitempty"`
	// contains filtered or unexported fields
}

SetStateRequest is the request for SetState.

func (*SetStateRequest) CloneMessageVT

func (m *SetStateRequest) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*SetStateRequest) CloneVT

func (m *SetStateRequest) CloneVT() *SetStateRequest

func (*SetStateRequest) EqualMessageVT

func (this *SetStateRequest) EqualMessageVT(thatMsg any) bool

func (*SetStateRequest) EqualVT

func (this *SetStateRequest) EqualVT(that *SetStateRequest) bool

func (*SetStateRequest) GetStateJson

func (x *SetStateRequest) GetStateJson() string

func (*SetStateRequest) MarshalJSON

func (x *SetStateRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SetStateRequest to JSON.

func (*SetStateRequest) MarshalProtoJSON

func (x *SetStateRequest) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SetStateRequest message to JSON.

func (*SetStateRequest) MarshalProtoText

func (x *SetStateRequest) MarshalProtoText() string

func (*SetStateRequest) MarshalToSizedBufferVT

func (m *SetStateRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SetStateRequest) MarshalToVT

func (m *SetStateRequest) MarshalToVT(dAtA []byte) (int, error)

func (*SetStateRequest) MarshalVT

func (m *SetStateRequest) MarshalVT() (dAtA []byte, err error)

func (*SetStateRequest) ProtoMessage

func (*SetStateRequest) ProtoMessage()

func (*SetStateRequest) Reset

func (x *SetStateRequest) Reset()

func (*SetStateRequest) SizeVT

func (m *SetStateRequest) SizeVT() (n int)

func (*SetStateRequest) String

func (x *SetStateRequest) String() string

func (*SetStateRequest) UnmarshalJSON

func (x *SetStateRequest) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SetStateRequest from JSON.

func (*SetStateRequest) UnmarshalProtoJSON

func (x *SetStateRequest) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SetStateRequest message from JSON.

func (*SetStateRequest) UnmarshalVT

func (m *SetStateRequest) UnmarshalVT(dAtA []byte) error

type SetStateResponse

type SetStateResponse struct {

	// Seqno is the sequence number after the update.
	Seqno uint64 `protobuf:"varint,1,opt,name=seqno,proto3" json:"seqno,omitempty"`
	// contains filtered or unexported fields
}

SetStateResponse is the response for SetState.

func (*SetStateResponse) CloneMessageVT

func (m *SetStateResponse) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*SetStateResponse) CloneVT

func (m *SetStateResponse) CloneVT() *SetStateResponse

func (*SetStateResponse) EqualMessageVT

func (this *SetStateResponse) EqualMessageVT(thatMsg any) bool

func (*SetStateResponse) EqualVT

func (this *SetStateResponse) EqualVT(that *SetStateResponse) bool

func (*SetStateResponse) GetSeqno

func (x *SetStateResponse) GetSeqno() uint64

func (*SetStateResponse) MarshalJSON

func (x *SetStateResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SetStateResponse to JSON.

func (*SetStateResponse) MarshalProtoJSON

func (x *SetStateResponse) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SetStateResponse message to JSON.

func (*SetStateResponse) MarshalProtoText

func (x *SetStateResponse) MarshalProtoText() string

func (*SetStateResponse) MarshalToSizedBufferVT

func (m *SetStateResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SetStateResponse) MarshalToVT

func (m *SetStateResponse) MarshalToVT(dAtA []byte) (int, error)

func (*SetStateResponse) MarshalVT

func (m *SetStateResponse) MarshalVT() (dAtA []byte, err error)

func (*SetStateResponse) ProtoMessage

func (*SetStateResponse) ProtoMessage()

func (*SetStateResponse) Reset

func (x *SetStateResponse) Reset()

func (*SetStateResponse) SizeVT

func (m *SetStateResponse) SizeVT() (n int)

func (*SetStateResponse) String

func (x *SetStateResponse) String() string

func (*SetStateResponse) UnmarshalJSON

func (x *SetStateResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SetStateResponse from JSON.

func (*SetStateResponse) UnmarshalProtoJSON

func (x *SetStateResponse) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SetStateResponse message from JSON.

func (*SetStateResponse) UnmarshalVT

func (m *SetStateResponse) UnmarshalVT(dAtA []byte) error

type StateAtomManager

type StateAtomManager struct {
	// contains filtered or unexported fields
}

StateAtomManager manages state atom stores with lazy initialization.

func NewStateAtomManager

func NewStateAtomManager(b bus.Bus, objectStoreID, volumeID string) *StateAtomManager

NewStateAtomManager creates a new StateAtomManager. objectStoreID is the ID for the object store used to persist state atoms. volumeID is the volume ID where the object store will be created.

func (*StateAtomManager) GetOrCreateStore

func (m *StateAtomManager) GetOrCreateStore(ctx context.Context, storeID string) (StateAtomStore, error)

GetOrCreateStore gets or creates a state atom store by ID.

func (*StateAtomManager) Release

func (m *StateAtomManager) Release()

Release releases all resources held by the manager.

type StateAtomResource

type StateAtomResource struct {
	// contains filtered or unexported fields
}

StateAtomResource wraps a StateAtomStore for resource access. It implements the StateAtomResourceService RPC interface.

func NewStateAtomResource

func NewStateAtomResource(store StateAtomStore) *StateAtomResource

NewStateAtomResource creates a new StateAtomResource.

func (*StateAtomResource) GetMux

func (r *StateAtomResource) GetMux() srpc.Invoker

GetMux returns the RPC mux.

func (*StateAtomResource) GetState

GetState returns the current state.

func (*StateAtomResource) SetState

SetState updates the state.

func (*StateAtomResource) WatchState

WatchState watches for state changes.

type StateAtomStore

type StateAtomStore interface {
	// GetStoreID returns the unique identifier for this store.
	GetStoreID() string

	// Get returns the current state JSON and sequence number.
	Get(ctx context.Context) (stateJson string, seqno uint64, err error)

	// Set updates the state JSON and returns the new sequence number.
	Set(ctx context.Context, stateJson string) (seqno uint64, err error)

	// WaitSeqno blocks until the seqno is >= the given value.
	WaitSeqno(ctx context.Context, minSeqno uint64) (uint64, error)
}

StateAtomStore is the interface for state atom storage backends.

type WatchStateRequest

type WatchStateRequest struct {
	// contains filtered or unexported fields
}

WatchStateRequest is the request for WatchState.

func (*WatchStateRequest) CloneMessageVT

func (m *WatchStateRequest) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WatchStateRequest) CloneVT

func (m *WatchStateRequest) CloneVT() *WatchStateRequest

func (*WatchStateRequest) EqualMessageVT

func (this *WatchStateRequest) EqualMessageVT(thatMsg any) bool

func (*WatchStateRequest) EqualVT

func (this *WatchStateRequest) EqualVT(that *WatchStateRequest) bool

func (*WatchStateRequest) MarshalJSON

func (x *WatchStateRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WatchStateRequest to JSON.

func (*WatchStateRequest) MarshalProtoJSON

func (x *WatchStateRequest) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WatchStateRequest message to JSON.

func (*WatchStateRequest) MarshalProtoText

func (x *WatchStateRequest) MarshalProtoText() string

func (*WatchStateRequest) MarshalToSizedBufferVT

func (m *WatchStateRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WatchStateRequest) MarshalToVT

func (m *WatchStateRequest) MarshalToVT(dAtA []byte) (int, error)

func (*WatchStateRequest) MarshalVT

func (m *WatchStateRequest) MarshalVT() (dAtA []byte, err error)

func (*WatchStateRequest) ProtoMessage

func (*WatchStateRequest) ProtoMessage()

func (*WatchStateRequest) Reset

func (x *WatchStateRequest) Reset()

func (*WatchStateRequest) SizeVT

func (m *WatchStateRequest) SizeVT() (n int)

func (*WatchStateRequest) String

func (x *WatchStateRequest) String() string

func (*WatchStateRequest) UnmarshalJSON

func (x *WatchStateRequest) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WatchStateRequest from JSON.

func (*WatchStateRequest) UnmarshalProtoJSON

func (x *WatchStateRequest) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WatchStateRequest message from JSON.

func (*WatchStateRequest) UnmarshalVT

func (m *WatchStateRequest) UnmarshalVT(dAtA []byte) error

type WatchStateResponse

type WatchStateResponse struct {

	// StateJson is the current state as a JSON string.
	StateJson string `protobuf:"bytes,1,opt,name=state_json,json=stateJson,proto3" json:"stateJson,omitempty"`
	// Seqno is the sequence number of this state version.
	Seqno uint64 `protobuf:"varint,2,opt,name=seqno,proto3" json:"seqno,omitempty"`
	// contains filtered or unexported fields
}

WatchStateResponse is the response for WatchState.

func (*WatchStateResponse) CloneMessageVT

func (m *WatchStateResponse) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*WatchStateResponse) CloneVT

func (m *WatchStateResponse) CloneVT() *WatchStateResponse

func (*WatchStateResponse) EqualMessageVT

func (this *WatchStateResponse) EqualMessageVT(thatMsg any) bool

func (*WatchStateResponse) EqualVT

func (this *WatchStateResponse) EqualVT(that *WatchStateResponse) bool

func (*WatchStateResponse) GetSeqno

func (x *WatchStateResponse) GetSeqno() uint64

func (*WatchStateResponse) GetStateJson

func (x *WatchStateResponse) GetStateJson() string

func (*WatchStateResponse) MarshalJSON

func (x *WatchStateResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WatchStateResponse to JSON.

func (*WatchStateResponse) MarshalProtoJSON

func (x *WatchStateResponse) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WatchStateResponse message to JSON.

func (*WatchStateResponse) MarshalProtoText

func (x *WatchStateResponse) MarshalProtoText() string

func (*WatchStateResponse) MarshalToSizedBufferVT

func (m *WatchStateResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WatchStateResponse) MarshalToVT

func (m *WatchStateResponse) MarshalToVT(dAtA []byte) (int, error)

func (*WatchStateResponse) MarshalVT

func (m *WatchStateResponse) MarshalVT() (dAtA []byte, err error)

func (*WatchStateResponse) ProtoMessage

func (*WatchStateResponse) ProtoMessage()

func (*WatchStateResponse) Reset

func (x *WatchStateResponse) Reset()

func (*WatchStateResponse) SizeVT

func (m *WatchStateResponse) SizeVT() (n int)

func (*WatchStateResponse) String

func (x *WatchStateResponse) String() string

func (*WatchStateResponse) UnmarshalJSON

func (x *WatchStateResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WatchStateResponse from JSON.

func (*WatchStateResponse) UnmarshalProtoJSON

func (x *WatchStateResponse) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WatchStateResponse message from JSON.

func (*WatchStateResponse) UnmarshalVT

func (m *WatchStateResponse) UnmarshalVT(dAtA []byte) error

Jump to

Keyboard shortcuts

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