config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpYaml

func DumpYaml(config *Configuration)

DumpYaml dumps the config to stdout.

Types

type API

type API struct {
	Port   int    `yaml:"port"`
	Prefix string `yaml:"prefix,omitempty"`
	ACL    string `yaml:"acl,omitempty"`
	Debug  bool   `yaml:"debug,omitempty"`
}

API holds the API configuration.

type Configuration

type Configuration struct {
	Listeners Listeners `yaml:"listeners"`
	Upstreams Upstreams `yaml:"upstreams"`

	HttpCache *cache.HttpCacheConfig          `yaml:"cache"`
	Provider  *provider.ProviderBackendConfig `yaml:"provider"`

	Cluster *cluster.Config `yaml:"cluster"`

	API *API `yaml:"api"`
	Log *Log `yaml:"logging"`
}

Configuration is the root configuration.

func (*Configuration) Validate

func (c *Configuration) Validate() error

Validate validates the configuration.

type Global

type Global struct {
	ApplicationName string `yaml:"-"`
	HTTPAddr        string `yaml:"host"`
}

Global holds the global configuration.

type Listener

type Listener struct {
	Addr string `yaml:"addr"`
}

Listener holds the listener config.

type Listeners

type Listeners map[string]*Listener

Listeners holds the listener configs.

func (Listeners) Validate

func (l Listeners) Validate() error

Validate validates the listener config.

type Loader

type Loader struct {
	Events chan bool
	// contains filtered or unexported fields
}

Loader loads a configuration from file.

func NewLoader

func NewLoader(path string, watch bool, interval time.Duration) (*Loader, error)

NewFileLoader creates a new config Loader.

func (*Loader) AutoReload

func (l *Loader) AutoReload() bool

AutoReload returns true if auto-reloading is enabled.

func (*Loader) Checksum

func (l *Loader) Checksum() string

Checksum returns the calculated checksum of the config.

func (*Loader) Close

func (l *Loader) Close()

Close closes the events channel.

func (*Loader) Config

func (l *Loader) Config() *Configuration

Config returns the loaded config.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) (bool, error)

Load reads the YAML-formatted config.

func (*Loader) Path

func (l *Loader) Path() string

Path returns the file path.

func (*Loader) Watch

func (l *Loader) Watch(ctx context.Context) error

Watch watches and reloads the config file if changed.

type Log

type Log struct {
	Level  string `yaml:"level,omitempty"`
	Format string `yaml:"format,omitempty"`
	Color  bool   `yaml:"color,omitempty"`

	File       string `yaml:"file,omitempty"`
	MaxSize    int    `yaml:"max_size,omitempty"`
	MaxAge     int    `yaml:"max_age,omitempty"`
	MaxBackups int    `yaml:"max_backups,omitempty"`
	Compress   bool   `yaml:"compress,omitempty"`
}

Log holds the logger configuration.

type Upstream

type Upstream struct {
	Name string `yaml:"name"`
	Addr string `yaml:"addr"`
	Path string `yaml:"path"`
}

Upstream holds the upstream target config.

type Upstreams

type Upstreams []*Upstream

Upstreams holds the upstream configs.

func (Upstreams) Validate

func (u Upstreams) Validate() error

Validate validates the upstream config.

Jump to

Keyboard shortcuts

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