config

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PortENV              = "PORT"            // runtime settings
	ConfigDirLocationENV = "CONFIG_LOCATION" // config settings
	AppSessionKeyENV     = "APP_SESSION_KEY" // Session/Auth key used to encrypt cookies with

	APIEndpointENV = "API_ENDPOINT" // client settings
	ForceTraceENV  = "API_FORCE_TRACE"

	// Other constants
	DefaultConfigName          = "config"
	DefaultConfigLocation      = "./.config"
	DefaultCredentialsLocation = "./.secrets"
	DefaultEndpoint            = "http://localhost:8080" // only really useful for testing ...
)

Variables

View Source
var (
	// ErrMissingConfigurator indicates that the config package is not initialized
	ErrMissingConfigurator = errors.New("missing configurator")
	// ErrInitializingConfiguration indicates that the client could not be initialized
	ErrInitializingConfiguration = errors.New("error initializing configuration")
	// ErrInvalidConfiguration indicates that parameters used to configure the service were invalid
	ErrInvalidConfiguration = errors.New("invalid configuration")
)

Functions

func AppSessionKey added in v0.2.0

func AppSessionKey() string

AppSessionKey is initialized from ENV['APP_SESSION_KEY'] or randomly generated on startup, if not provided.

func SetConfigLocation

func SetConfigLocation(loc string)

SetConfigLocation sets the actual location without checking if the location actually exists !

func SetProvider

func SetProvider(provider ConfigProvider)

Types

type ConfigProvider added in v0.2.0

type ConfigProvider interface {
	// AppInfo returns static information about the app or service
	Info() *Info
	// Settings returns the app settings, if configured, or falls back to a default, minimal configuration
	Settings() *settings.DialSettings
	// ConfigLocation returns the path to the config location, if set, or the default location otherwise.
	ConfigLocation() string // './.config' unless explicitly set.
	// SetConfigLocation explicitly sets the location where the configuration is expected. The location's existence is NOT verified.
	SetConfigLocation(string)
}

func GetConfig

func GetConfig() ConfigProvider

func NewLocalConfigProvider

func NewLocalConfigProvider() ConfigProvider

type Info

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

Info holds static information about a service or API

func NewAppInfo

func NewAppInfo(name, shortName, copyright, about string, major, minor, fix int) Info

func (*Info) About

func (i *Info) About() string

func (*Info) Copyright

func (i *Info) Copyright() string

func (*Info) FixVersion

func (i *Info) FixVersion() int

func (*Info) MajorVersion

func (i *Info) MajorVersion() int

func (*Info) MinorVersion

func (i *Info) MinorVersion() int

func (*Info) Name

func (i *Info) Name() string

func (*Info) ServerString

func (i *Info) ServerString() string

func (*Info) ShortName

func (i *Info) ShortName() string

func (*Info) UserAgentString

func (i *Info) UserAgentString() string

func (*Info) VersionString

func (i *Info) VersionString() string

Jump to

Keyboard shortcuts

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