Documentation
¶
Index ¶
- Variables
- type MongoDBStore
- func (s *MongoDBStore) Get(ctx context.Context, key string) (string, bool, error)
- func (s *MongoDBStore) GetAll(ctx context.Context) (map[string]string, error)
- func (s *MongoDBStore) Replace(ctx context.Context, key, old, value string) (string, error)
- func (s *MongoDBStore) Set(ctx context.Context, key, value string) error
- func (s *MongoDBStore) SetDefault(ctx context.Context, key, value string) (string, error)
- type SQLStore
- func (s *SQLStore) Get(ctx context.Context, key string) (string, bool, error)
- func (s *SQLStore) GetAll(ctx context.Context) (map[string]string, error)
- func (s *SQLStore) Replace(ctx context.Context, key, old, value string) (string, error)
- func (s *SQLStore) Set(ctx context.Context, key, value string) error
- func (s *SQLStore) SetDefault(ctx context.Context, key, value string) (string, error)
- type Service
- type Store
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type MongoDBStore ¶
type MongoDBStore struct {
// contains filtered or unexported fields
}
MongoDBStore persists runtime settings in MongoDB.
func NewMongoDBStore ¶
NewMongoDBStore uses the shared runtime_settings collection.
func (*MongoDBStore) Replace ¶ added in v0.1.107
Replace updates key to value only while it still holds old, then reads back the winner. The filtered update is atomic on the document, so of two instances replacing the same old value only one does.
func (*MongoDBStore) Set ¶
func (s *MongoDBStore) Set(ctx context.Context, key, value string) error
Set upserts a persisted value.
func (*MongoDBStore) SetDefault ¶ added in v0.1.85
SetDefault inserts value unless key exists, then reads back the winner. An upsert with $setOnInsert is atomic on the _id, so two instances initialising at once cannot both believe they won.
type SQLStore ¶
type SQLStore struct {
// contains filtered or unexported fields
}
SQLStore persists runtime settings in SQLite or PostgreSQL.
func NewSQLStore ¶
NewSQLStore initializes the shared runtime-settings table.
func (*SQLStore) Replace ¶ added in v0.1.107
Replace updates key to value only while it still holds old, then reads back the winner. The conditional UPDATE is atomic in both SQLite and PostgreSQL, so of two instances replacing the same old value only one does.
func (*SQLStore) SetDefault ¶ added in v0.1.85
SetDefault inserts value unless key exists, then reads back the winner. ON CONFLICT DO NOTHING is atomic in both SQLite and PostgreSQL, so two instances inserting at once cannot both believe they won.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service validates, persists, applies, and reconciles registered settings.
func New ¶
func New(ctx context.Context, backend storage.Storage, registered []ext.RuntimeSetting) (*Service, error)
New restores registered settings and starts cross-instance reconciliation.
func (*Service) List ¶
func (s *Service) List() []ext.SettingDescriptor
List returns the current setting descriptors in stable key order.
type Store ¶
type Store interface {
Get(ctx context.Context, key string) (value string, found bool, err error)
// GetAll returns every persisted value by key in one read.
GetAll(ctx context.Context) (map[string]string, error)
Set(ctx context.Context, key, value string) error
// SetDefault stores value only when key has no value yet, and returns
// whatever is stored afterwards: value, or the one that was already
// there. It is atomic, so instances racing to initialise the same key
// all end up with the same winner.
SetDefault(ctx context.Context, key, value string) (string, error)
// Replace stores value only when key still holds old, and returns
// whatever is stored afterwards: value, or the one another instance
// wrote first. It is atomic, so instances racing to replace the same
// value all end up with the same winner.
Replace(ctx context.Context, key, old, value string) (string, error)
}
Store persists deployment-wide runtime-setting values.