config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package config contains configuration options for the server as well as various config contstants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectFormat

func DetectFormat(file string) jelly.Format

DetectFormat detects the format of a given configuration file and returns the Format that can decode it. Returns NoFormat if the format could not be detected.

func Dump

func Dump(cfg jelly.Config) []byte

Dump dumps the configuration into the bytes in a formatted file. This is the complete representation of the current state of the Config, and if parsed by Load, would result in an equivalent config.

The config will be dumped in the same format it was loaded with, or will default to YAML if the cfg was created without loading from a data stream. To encode a Config in a specific format, call Encode(cfg) on the desired Format.

This function will cause a panic if there is a problem marshaling the config data in its format.

func SupportedFormats

func SupportedFormats() []jelly.Format

SupportedFormats returns a list of formats that the config module supports decoding. Includes all but NoFormat.

Types

type ConnectorRegistry

type ConnectorRegistry struct {
	DisableDefaults bool
	// contains filtered or unexported fields
}

ConnectorRegistry holds registered connecter functions for opening store structs on database connections.

The zero value can be immediately used and will have the built-in default and pre-rolled connectors available. This can be disabled by setting DisableDefaults to true before attempting to use it.

func (*ConnectorRegistry) Connect

Connect opens a connection to the configured database, returning a generic db.Store. The Store can then be cast to the appropriate type by APIs in their init method.

func (*ConnectorRegistry) List

func (cr *ConnectorRegistry) List(engine jelly.DBType) []string

List returns an alphabetized list of all currently registered connector names for an engine.

func (*ConnectorRegistry) Register

func (cr *ConnectorRegistry) Register(engine jelly.DBType, name string, connector func(jelly.DatabaseConfig) (jelly.Store, error)) error

type Environment

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

Environment holds all options such as config providers that would normally be globally set. Users of Jelly are generally better off using the jelly.Environment type, as that contains a complete environment spanning the config package and any others that contain the concept of registration of certain key procedures and types prior to actual use.

func (*Environment) Load

func (env *Environment) Load(file string) (jelly.Config, error)

Load loads a configuration from a JSON or YAML file. The format of the file is determined by examining its extension; files ending in .json are parsed as JSON files, and files ending in .yaml or .yml are parsed as YAML files. Other extensions are not supported. The extension is not case-sensitive.

Ensure Register is called on the Environment (or an owning jelly.Environment) with all config sections that will be present in the loaded file.

func (*Environment) Register

func (env *Environment) Register(name string, provider func() jelly.APIConfig) error

Jump to

Keyboard shortcuts

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