config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(elems ...string) string

func MissingKeyMessage

func MissingKeyMessage(key string) func(format string, args ...any) string

Types

type Config

type Config struct {
	Configurable
}

func New

func New(configurable Configurable) *Config

func (Config) Bool

func (c Config) Bool(ctx context.Context, key string, defaultTo ...bool) (bool, error)

func (Config) Bytes

func (c Config) Bytes(ctx context.Context, key string, defaultTo ...byte) ([]byte, error)

func (Config) Float

func (c Config) Float(ctx context.Context, key string, defaultTo ...float64) (float64, error)

func (Config) Int

func (c Config) Int(ctx context.Context, key string, defaultTo ...int) (int, error)

func (Config) String

func (c Config) String(ctx context.Context, key string, defaultTo ...string) (string, error)

func (Config) Strings

func (c Config) Strings(ctx context.Context, key string, defaultTo ...string) ([]string, error)

func (Config) URL

func (c Config) URL(ctx context.Context, key string, defaultTo ...*url.URL) (*url.URL, error)

type Configurable

type Configurable interface {
	Refresh(ctx context.Context) error
	Merge(ctx context.Context, configurable Configurable) (Configurable, error)
	Get(ctx context.Context, key string) (any, error)
}

type InMemoryConfig

type InMemoryConfig struct {
	sync.RWMutex
	Values map[any]any
	// contains filtered or unexported fields
}

func NewInMemoryConfig

func NewInMemoryConfig(values ...map[any]any) *InMemoryConfig

func (*InMemoryConfig) Get

func (i *InMemoryConfig) Get(ctx context.Context, key string) (any, error)

func (*InMemoryConfig) Merge

func (i *InMemoryConfig) Merge(ctx context.Context, configurable Configurable) (Configurable, error)

func (*InMemoryConfig) Refresh

func (i *InMemoryConfig) Refresh(_ context.Context) error

Jump to

Keyboard shortcuts

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