Movatterモバイル変換


[0]ホーム

URL:


runtimeconfig

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:9Imported by:0

Details

Repository

github.com/coder/coder

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

View Source
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

func JSONString(vany)string

Types

typeEntryMarshaller

type EntryMarshaller interface {fmt.Stringer}

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

func (*Manager) OrganizationResolver(dbStore, orgIDuuid.UUID)Resolver

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()'.

func (*Manager)Resolver

func (*Manager) Resolver(dbStore)Resolver

Resolver is the deployment wide namespace for runtime configuration.If you are trying to namespace a configuration, orgs for example, useOrganizationResolver.

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 (mNamespacedResolver) GetRuntimeConfig(ctxcontext.Context, keystring) (string,error)

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) GetRuntimeConfig(context.Context,string) (string,error)

func (NoopResolver)UpsertRuntimeConfig

func (NoopResolver) UpsertRuntimeConfig(context.Context,string,string)error

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 (mStoreResolver) GetRuntimeConfig(ctxcontext.Context, keystring) (string,error)

func (StoreResolver)UpsertRuntimeConfig

func (mStoreResolver) UpsertRuntimeConfig(ctxcontext.Context, key, valstring)error

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp