dynconfig

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RDB          rueidis.Client
	Prefix       string
	PollInterval time.Duration // Default: 10s.
	Logger       gochainedlog.Logger
}

Config holds manager configuration.

type HandlerOverride

type HandlerOverride struct {
	Concurrency int           `json:"concurrency,omitempty"`
	Timeout     time.Duration `json:"timeout,omitempty"`
	MaxAttempts int           `json:"max_attempts,omitempty"`
}

HandlerOverride holds per-handler dynamic settings.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager polls Redis for configuration changes and maintains an atomic snapshot.

func NewManager

func NewManager(cfg Config) *Manager

NewManager creates a new dynamic configuration manager.

func (*Manager) DeleteGlobalField

func (m *Manager) DeleteGlobalField(ctx context.Context, field string) error

DeleteGlobalField deletes a global config field.

func (*Manager) DeleteHandler

func (m *Manager) DeleteHandler(ctx context.Context, taskType string) error

DeleteHandler deletes all overrides for a task type.

func (*Manager) Get

func (m *Manager) Get() *Snapshot

Get returns the current configuration snapshot.

func (*Manager) GetAllGlobal

func (m *Manager) GetAllGlobal(ctx context.Context) (map[string]string, error)

GetAllGlobal returns all global config fields.

func (*Manager) GetAllHandler

func (m *Manager) GetAllHandler(ctx context.Context, taskType string) (map[string]string, error)

GetAllHandler returns all config fields for a task type.

func (*Manager) GetHandler

func (m *Manager) GetHandler(taskType string) (HandlerOverride, bool)

GetHandler returns the handler override for a task type, if any.

func (*Manager) SetGlobal

func (m *Manager) SetGlobal(ctx context.Context, field, value string) error

SetGlobal sets a global config field.

func (*Manager) SetHandler

func (m *Manager) SetHandler(ctx context.Context, taskType, field, value string) error

SetHandler sets a handler config field for a specific task type.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start begins the polling loop. Non-blocking.

func (*Manager) Stop

func (m *Manager) Stop()

Stop halts the polling loop.

type Snapshot

type Snapshot struct {
	// Global settings.
	MaxConcurrency        int           `json:"max_concurrency,omitempty"`
	SchedulerTickInterval time.Duration `json:"scheduler_tick_interval,omitempty"`

	// Per-handler overrides (keyed by task type).
	Handlers map[string]HandlerOverride `json:"handlers,omitempty"`
}

Snapshot holds a point-in-time view of dynamic configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL