configio

package module
v0.0.0-...-492bda3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: MIT Imports: 2 Imported by: 18

README

configio

configio is a specification for general purpose config data storage and retrieval. Any type satisfying Marshaler interface can be managed via ConfigManager interface.

$ go get -u -v github.com/sdeoras/configio/...

Documentation

Overview

configio defines a generic interface for config management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
	Func func(ctx context.Context, data interface{}, err error) <-chan error
	Data interface{}
	Err  error
	Chan chan struct{}
}

Callback is the bookkeeping data for each registered callback

type Config

type Config interface {
	Key() string
	Marshal() ([]byte, error)
	Unmarshal(b []byte) error
}

Config defines the behavior of a type that can act as a config parameter Any such type should provide serialization methods and ability to get a key

type ConfigManager

type ConfigManager interface {
	// Unmarshal unmarshals into marshaler
	Unmarshal(config Config) error
	// Marshal marshals data in marshaler
	Marshal(config Config) error
	io.Closer
}

ConfigManager defines an interface to perform read/write on config params

type ConfigManagerWithWatch

type ConfigManagerWithWatch interface {
	// Unmarshal unmarshals into marshaler
	Unmarshal(config Config) error
	// Marshal marshals data in marshaler
	Marshal(config Config) error
	// Watch registers a callback function
	Watch(name string, data interface{},
		f func(ctx context.Context, data interface{}, err error) <-chan error) <-chan struct{}
	io.Closer
}

ConfigManagerWithWatch defines an interface to access config params

type ConfigReader

type ConfigReader interface {
	// Unmarshal unmarshals into marshaler
	Unmarshal(config Config) error
	io.Closer
}

ConfigReader defines an interface to perform read operation on config params

type ConfigWatcher

type ConfigWatcher interface {
	// Watch registers a callback function
	Watch(name string, data interface{},
		f func(ctx context.Context, data interface{}, err error) <-chan error) <-chan struct{}
	io.Closer
}

ConfigWatcher defines an interface to perform a watch on config changes. Watch registers a function that gets executed on config changes. If an error occurs on function execution, the function is called again with that error passed in as an input argument and is removed from the registry

type ConfigWriter

type ConfigWriter interface {
	// Marshal marshals data in marshaler
	Marshal(config Config) error
	io.Closer
}

ConfigWriter defines an interface to perform write operation on config params

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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