Documentation
¶
Overview ¶
Package poya provides dynamic runtime configuration and configuration management for Go applications. It supports type-safe generic config values (scalars and structs) synced from etcd, Redis, HashiCorp Vault, MySQL, or PostgreSQL backends. Developers register DcValue[T] instances and call Get() to read the latest values for use cases like feature flags, service discovery, and runtime parameter tuning.
Index ¶
- func Register[T any](s *SDK, key string, val *DcValue[T])
- func RegisterConfig(s *SDK, structVal any)
- type Config
- type DcValue
- func (d *DcValue[T]) Get() T
- func (d *DcValue[T]) InternalAtomic() *atomic.Value
- func (d *DcValue[T]) InternalDefault() T
- func (d *DcValue[T]) InternalKey(key string)
- func (d *DcValue[T]) InternalKind() EntryKind
- func (d *DcValue[T]) InternalSet(val T)
- func (d *DcValue[T]) InternalSetJSON(raw []byte) error
- func (d *DcValue[T]) SetDefaultAndValue(val T)
- type EntryKind
- type SDK
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterConfig ¶
Types ¶
type DcValue ¶
type DcValue[T any] struct { // contains filtered or unexported fields }
DcValue is a dynamically-configured value of type T for dynamic configuration use cases. Developers create instances via NewDcValue and pass them around the application. Only Get() is public — all mutation is handled internally by the SDK.
For scalar types (string, int, bool, float64, etc.), the SDK parses raw provider values via type switch. For struct types, the SDK JSON-decodes the raw provider value into T. For slice types ([]string, []int, etc.), the SDK JSON-decodes the raw value into a new slice of T.
func NewDcValue ¶
NewDcValue creates a new DcValue with the given default. The key is set later by the SDK during Register.
func (*DcValue[T]) Get ¶
func (d *DcValue[T]) Get() T
Get returns the current value. This is the only method exposed to the developer. Reads are lock-free via atomic.Value.
func (*DcValue[T]) InternalAtomic ¶
func (*DcValue[T]) InternalDefault ¶
func (d *DcValue[T]) InternalDefault() T
func (*DcValue[T]) InternalKey ¶
func (*DcValue[T]) InternalKind ¶
func (*DcValue[T]) InternalSet ¶
func (d *DcValue[T]) InternalSet(val T)
func (*DcValue[T]) InternalSetJSON ¶
func (*DcValue[T]) SetDefaultAndValue ¶
func (d *DcValue[T]) SetDefaultAndValue(val T)
SetDefaultAndValue sets the default value, current value, and kind based on the type of val. The val must be assignable to T. This method is intended for use by decode hooks and similar reflection-based initialization code.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
etcd
command
Example: etcd provider
|
Example: etcd provider |
|
file
command
Example: File provider
|
Example: File provider |
|
mysql
command
Example: MySQL provider
|
Example: MySQL provider |
|
postgresql
command
Example: PostgreSQL provider
|
Example: PostgreSQL provider |
|
redis
command
Example: Redis provider
|
Example: Redis provider |
|
vault
command
Example: HashiCorp Vault provider
|
Example: HashiCorp Vault provider |
|
Package hooks provides mapstructure decode hooks for use with DcValue[T] fields.
|
Package hooks provides mapstructure decode hooks for use with DcValue[T] fields. |
|
Package logger provides a minimal structured-logger interface and a default stdlib-based implementation for the poya SDK.
|
Package logger provides a minimal structured-logger interface and a default stdlib-based implementation for the poya SDK. |
|
otel
Package otel implements the poya Metrics interface using OpenTelemetry.
|
Package otel implements the poya Metrics interface using OpenTelemetry. |
|
Package provider defines the Provider interface for configuration backends.
|
Package provider defines the Provider interface for configuration backends. |
|
etcd
Package etcd implements the provider.Provider interface for etcd configuration backends.
|
Package etcd implements the provider.Provider interface for etcd configuration backends. |
|
file
Package file implements provider.Provider for local file-based configuration.
|
Package file implements provider.Provider for local file-based configuration. |
|
mysql
Package mysql implements the provider.Provider interface for MySQL configuration backends.
|
Package mysql implements the provider.Provider interface for MySQL configuration backends. |
|
postgresql
Package postgresql implements the provider.Provider interface for PostgreSQL configuration backends.
|
Package postgresql implements the provider.Provider interface for PostgreSQL configuration backends. |
|
redis
Package redis implements the provider.Provider interface for Redis configuration backends.
|
Package redis implements the provider.Provider interface for Redis configuration backends. |
|
vault
Package vault implements the provider.Provider interface for HashiCorp Vault KV v2 backends.
|
Package vault implements the provider.Provider interface for HashiCorp Vault KV v2 backends. |