loader

package
v0.0.0-...-82b0641 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

package loader manages loading from multiple sources

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader interface {
	// Stop the loader
	Close() error
	// Load the sources
	Load(...source.Source) error
	// A Snapshot of loaded config
	Snapshot() (*Snapshot, error)
	// Force sync of sources
	Sync() error
	// Watch for changes
	Watch(...string) (Watcher, error)

	Values(*source.ChangeSet) (reader.Values, error)
	Reader() reader.Reader
}

Loader manages loading sources

func NewLoader

func NewLoader(opts ...Option) Loader

type Option

type Option func(o *Options)

func WithReader

func WithReader(r reader.Reader) Option

WithReader sets the config reader

func WithWatch

func WithWatch(t bool) Option

WithReader sets the config reader

type Options

type Options struct {
	Reader reader.Reader
	Watch  bool

	// for alternative data
	Context context.Context
}

func NewOptions

func NewOptions(opts ...Option) Options

type Snapshot

type Snapshot struct {
	// The merged ChangeSet
	ChangeSet *source.ChangeSet
	// Deterministic and comparable version of the snapshot
	Version string
}

Snapshot is a merged ChangeSet

func (*Snapshot) Clone

func (s *Snapshot) Clone() *Snapshot

Copy snapshot

type Watcher

type Watcher interface {
	// First call to next may return the current Snapshot
	// If you are watching a path then only the data from
	// that path is returned.
	Next() (*Snapshot, error)
	// Stop watching for changes
	Stop() error
}

Watcher lets you watch sources and returns a merged ChangeSet

Jump to

Keyboard shortcuts

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