config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvDevelopment = "dev"
	EnvProduction  = "prod"

	ModeHttp = "http"
	ModeCli  = "cli"

	DefaultModeKey             = "MELODY_DEFAULT_MODE"
	EnvKey                     = "MELODY_ENV"
	HttpAddressKey             = "MELODY_HTTP_ADDRESS"
	HttpMaxRequestBodyBytesKey = "MELODY_HTTP_MAX_REQUEST_BODY_BYTES"
	CliNameKey                 = "MELODY_CLI_NAME"
	CliDescriptionKey          = "MELODY_CLI_DESCRIPTION"
	LogPathKey                 = "MELODY_LOG_PATH"
	LogLevelKey                = "MELODY_LOG_LEVEL"
	DefaultLocaleKey           = "MELODY_DEFAULT_LOCALE"
	PublicDirKey               = "MELODY_PUBLIC_DIR"
	StaticIndexFileKey         = "MELODY_STATIC_INDEX_FILE"
	StaticEnableCacheKey       = "MELODY_STATIC_ENABLE_CACHE"
	StaticCacheMaxAgeKey       = "MELODY_STATIC_CACHE_MAX_AGE"

	KernelDefaultMode             = "kernel.default_mode"
	KernelEnv                     = "kernel.environment"
	KernelHttpAddress             = "kernel.http_address"
	KernelHttpMaxRequestBodyBytes = "kernel.http.max_request_body_bytes"
	KernelCliName                 = "kernel.cli_name"
	KernelCliDescription          = "kernel.cli_description"
	KernelLogPath                 = "kernel.log_path"
	KernelLogLevel                = "kernel.log_level"
	KernelDefaultLocale           = "kernel.default_locale"
	KernelPublicDir               = "kernel.public_dir"
	KernelStaticIndexFile         = "kernel.static.index_file"
	KernelStaticEnableCache       = "kernel.static.enable_cache"
	KernelStaticCacheMaxAge       = "kernel.static.cache_max_age"

	KernelProjectDir = "kernel.project_dir"
	KernelLogsDir    = "kernel.logs_dir"
	KernelCacheDir   = "kernel.cache_dir"
)
View Source
const (
	ServiceConfig = "service.config"
)

Variables

This section is empty.

Functions

func ConfigMustFromContainer

func ConfigMustFromContainer(serviceContainer containercontract.Container) configcontract.Configuration

func ConfigMustFromResolver added in v1.1.0

func ConfigMustFromResolver(resolver containercontract.Resolver) configcontract.Configuration

func IntWithDefault added in v1.4.0

func IntWithDefault(configParameter configcontract.Parameter, defaultValue int) int

Types

type Configuration

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

func NewConfiguration

func NewConfiguration(
	environment *Environment,
	projectDirectory string,
) (*Configuration, error)

func (*Configuration) Cli

func (*Configuration) Get

func (instance *Configuration) Get(name string) configcontract.Parameter

func (*Configuration) Http

func (*Configuration) Kernel

func (*Configuration) MustGet

func (instance *Configuration) MustGet(name string) configcontract.Parameter

func (*Configuration) Names

func (instance *Configuration) Names() []string

func (*Configuration) Parameters

func (instance *Configuration) Parameters() ParameterMap

func (*Configuration) RegisterRuntime

func (instance *Configuration) RegisterRuntime(name string, value any)

func (*Configuration) Resolve

func (instance *Configuration) Resolve() error

type Environment

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

func NewEnvironment

func NewEnvironment(source configcontract.EnvironmentSource) (*Environment, error)

func (*Environment) All

func (instance *Environment) All() map[string]string

func (*Environment) Get

func (instance *Environment) Get(key string) (string, bool)

type EnvironmentSource

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

func NewEnvironmentSource

func NewEnvironmentSource(
	fileSystem fs.FS,
	baseDir string,
) *EnvironmentSource

func (*EnvironmentSource) Load

func (instance *EnvironmentSource) Load() (map[string]string, error)

type Parameter

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

func NewParameter

func NewParameter(environmentKey string, environmentValue any, value any, isDefault bool) *Parameter

func (*Parameter) Bool

func (instance *Parameter) Bool() (bool, error)

func (*Parameter) EnvironmentKey

func (instance *Parameter) EnvironmentKey() string

func (*Parameter) EnvironmentValue

func (instance *Parameter) EnvironmentValue() any

func (*Parameter) Int

func (instance *Parameter) Int() (int, error)

func (*Parameter) IsDefault

func (instance *Parameter) IsDefault() bool

func (*Parameter) MustString

func (instance *Parameter) MustString() string

func (*Parameter) String

func (instance *Parameter) String() string

func (*Parameter) Value

func (instance *Parameter) Value() any

type ParameterMap

type ParameterMap map[string]*Parameter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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