runtimeconfig
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package runtimeconfig contains logic for managing runtime configuration valuesstored in the database. Each coderd should have a Manager singleton instancethat can create a Resolver for runtime configuration CRUD.
TODO: Implement a caching layer for the Resolver so that we don't hit thedatabase on every request. Configuration values are not expected to changefrequently, so we should use pubsub to notify for updates.When implemented, the runtimeconfig will essentially be an in memory lookupwith a database for persistence.
Index¶
Constants¶
This section is empty.
Variables¶
var (// ErrEntryNotFound is returned when a runtime entry is not saved in the// store. It is essentially a 'sql.ErrNoRows'.ErrEntryNotFound =xerrors.New("entry not found")// ErrNameNotSet is returned when a runtime entry is created without a name.// This is more likely to happen on DeploymentEntry that has not called// Initialize().ErrNameNotSet =xerrors.New("name is not set"))
Functions¶
funcJSONString¶
Types¶
typeEntryMarshaller¶
EntryMarshaller requires all entries to marshal to and from a string.The final store value is a database `text` column.This also is compatible with serpent values.
typeEntryValue¶
type EntryValue interface {EntryMarshallerSet(string)error}
typeInitializer¶
type Initializer interface {Initialize(namestring)}
typeManager¶
type Manager struct{}
Manager is the singleton that produces resolvers for runtime configuration.TODO: Implement caching layer.
funcNewManager¶
func NewManager() *Manager
func (*Manager)OrganizationResolver¶
OrganizationResolver will namespace all runtime configuration to the providedorganization ID. Configuration values stored with a given organization ID requirethat the organization ID be provided to retrieve the value.No values set here will ever be returned by the call to 'Resolver()'.
typeNamespacedResolver¶
type NamespacedResolver struct {// contains filtered or unexported fields}
NamespacedResolver prefixes all keys with a namespace.Then defers to the underlying resolver for the actual operations.
funcOrganizationResolver¶
func OrganizationResolver(orgIDuuid.UUID, wrappedResolver)NamespacedResolver
func (NamespacedResolver)DeleteRuntimeConfig¶
func (mNamespacedResolver) DeleteRuntimeConfig(ctxcontext.Context, keystring)error
func (NamespacedResolver)GetRuntimeConfig¶
func (NamespacedResolver)UpsertRuntimeConfig¶
func (mNamespacedResolver) UpsertRuntimeConfig(ctxcontext.Context, key, valstring)error
typeNoopResolver¶
type NoopResolver struct{}
NoopResolver is a useful test device.
funcNewNoopResolver¶
func NewNoopResolver() *NoopResolver
func (NoopResolver)DeleteRuntimeConfig¶
func (NoopResolver) DeleteRuntimeConfig(context.Context,string)error
func (NoopResolver)GetRuntimeConfig¶
func (NoopResolver)UpsertRuntimeConfig¶
typeResolver¶
type Resolver interface {// GetRuntimeConfig gets a runtime setting by name.GetRuntimeConfig(ctxcontext.Context, namestring) (string,error)// UpsertRuntimeConfig upserts a runtime setting by name.UpsertRuntimeConfig(ctxcontext.Context, name, valstring)error// DeleteRuntimeConfig deletes a runtime setting by name.DeleteRuntimeConfig(ctxcontext.Context, namestring)error}
typeRuntimeEntry¶
type RuntimeEntry[TEntryValue] struct {// contains filtered or unexported fields}
RuntimeEntry are **only** runtime configurable. They are stored in thedatabase, and have no startup value or default value.
funcMustNew¶
func MustNew[TEntryValue](namestring)RuntimeEntry[T]
MustNew is like New but panics if an error occurs.
funcNew¶
func New[TEntryValue](namestring) (outRuntimeEntry[T], errerror)
New creates a new T instance with a defined name and value.
func (RuntimeEntry[T])Resolve¶
func (eRuntimeEntry[T]) Resolve(ctxcontext.Context, rResolver) (T,error)
Resolve attempts to resolve the runtime value of this field from the store via the given Resolver.
func (RuntimeEntry[T])SetRuntimeValue¶
func (eRuntimeEntry[T]) SetRuntimeValue(ctxcontext.Context, mResolver, val T)error
SetRuntimeValue attempts to update the runtime value of this field in the store via the given Mutator.
func (RuntimeEntry[T])UnsetRuntimeValue¶
func (eRuntimeEntry[T]) UnsetRuntimeValue(ctxcontext.Context, mResolver)error
UnsetRuntimeValue removes the runtime value from the store.
typeStore¶
type Store interface {GetRuntimeConfig(ctxcontext.Context, keystring) (string,error)UpsertRuntimeConfig(ctxcontext.Context, argdatabase.UpsertRuntimeConfigParams)errorDeleteRuntimeConfig(ctxcontext.Context, keystring)error}
Store is a subset of database.Store
typeStoreResolver¶
type StoreResolver struct {// contains filtered or unexported fields}
StoreResolver uses the database as the underlying store for runtime settings.
funcNewStoreResolver¶
func NewStoreResolver(dbStore) *StoreResolver
func (StoreResolver)DeleteRuntimeConfig¶
func (mStoreResolver) DeleteRuntimeConfig(ctxcontext.Context, keystring)error
func (StoreResolver)GetRuntimeConfig¶
func (StoreResolver)UpsertRuntimeConfig¶
func (mStoreResolver) UpsertRuntimeConfig(ctxcontext.Context, key, valstring)error