Documentation
¶
Index ¶
- type Controller
- type PluginDataState
- type ServiceWrapper
- func (s *ServiceWrapper) CompareAndSwap(pluginID, key, expectedRevision string, value any) (bool, error)
- func (s *ServiceWrapper) Delete(pluginID, key string) error
- func (s *ServiceWrapper) Get(pluginID, key string) (any, error)
- func (s *ServiceWrapper) GetSnapshot(pluginID, key string) (Snapshot, error)
- func (s *ServiceWrapper) Keys(pluginID string) ([]string, error)
- func (s *ServiceWrapper) ServiceShutdown() error
- func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error
- func (s *ServiceWrapper) Set(pluginID, key string, value any) error
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface {
ServiceStartup(ctx context.Context, options application.ServiceOptions) error
ServiceShutdown() error
Get(pluginID, key string) (any, error)
GetSnapshot(pluginID, key string) (Snapshot, error)
CompareAndSwap(pluginID, key, expectedRevision string, value any) (bool, error)
Set(pluginID, key string, value any) error
Delete(pluginID, key string) error
Keys(pluginID string) ([]string, error)
}
Controller provides a JSON key-value store for plugins to persist arbitrary data. Each key is stored as a separate JSON file under <stateRoot>/plugins/{pluginID}/data/.
func NewController ¶
func NewController(logger logging.Logger, state PluginDataState) Controller
NewController creates a new data store controller. Writes (Set, Delete, CompareAndSwap) create plugin data directories on demand; reads (Get, GetSnapshot, Keys) only open directories that already exist, so a missing directory reads as an empty store.
type PluginDataState ¶ added in v0.32.0
type PluginDataState interface {
// PluginData opens, creating on demand, a plugin's data directory. Used by writes.
PluginData(id string) (*appstate.ScopedRoot, error)
// PluginDataIfExists opens a plugin's data directory only if it exists. Used by reads.
PluginDataIfExists(id string) (*appstate.ScopedRoot, bool, error)
}
PluginDataState is the app state surface the controller needs.
type ServiceWrapper ¶ added in v0.4.0
type ServiceWrapper struct {
Ctrl Controller
}
ServiceWrapper is an explicit delegation wrapper around data.Controller.
func (*ServiceWrapper) CompareAndSwap ¶ added in v0.29.0
func (s *ServiceWrapper) CompareAndSwap(pluginID, key, expectedRevision string, value any) (bool, error)
func (*ServiceWrapper) Delete ¶ added in v0.4.0
func (s *ServiceWrapper) Delete(pluginID, key string) error
func (*ServiceWrapper) Get ¶ added in v0.4.0
func (s *ServiceWrapper) Get(pluginID, key string) (any, error)
func (*ServiceWrapper) GetSnapshot ¶ added in v0.29.0
func (s *ServiceWrapper) GetSnapshot(pluginID, key string) (Snapshot, error)
func (*ServiceWrapper) Keys ¶ added in v0.4.0
func (s *ServiceWrapper) Keys(pluginID string) ([]string, error)
func (*ServiceWrapper) ServiceShutdown ¶ added in v0.4.0
func (s *ServiceWrapper) ServiceShutdown() error
func (*ServiceWrapper) ServiceStartup ¶ added in v0.4.0
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error