klreader

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 4 Imported by: 0

README

Reader Loader

Loads config from an io.Reader

Usage

readerLoader := klreader.New(&klreader.Config{
    Parser: kpjson.Parser,
    Reader: strings.NewReader(`{"foo":"bar"}`),
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name          string
	Reader        io.Reader
	Parser        parser.Parser
	MaxRetry      int
	RetryDelay    time.Duration
	StopOnFailure bool
}

Config is the structure for the Loader's config

type Loader

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

Loader is the Loader's structure

func New

func New(cfg *Config) *Loader

New returns a new loader with the given config

func (*Loader) Load

func (l *Loader) Load(cfg konfig.Values) error

Load implements the konfig.Loader interface. It reads from its io.Reader and adds the data to the konfig.Values

func (*Loader) MaxRetry

func (l *Loader) MaxRetry() int

MaxRetry implements konfig.Loader interface and returns the maximum number of time Load method can be retried

func (*Loader) Name

func (l *Loader) Name() string

Name implements konfig.Loader. It returns the loader's name for metrics purpose.

func (*Loader) RetryDelay

func (l *Loader) RetryDelay() time.Duration

RetryDelay implements konfig.Loader interface and returns the delay between each retry

func (*Loader) StopOnFailure

func (l *Loader) StopOnFailure() bool

StopOnFailure returns whether a load failure should stop the config and the registered closers

Jump to

Keyboard shortcuts

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