scf4go

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 10 Imported by: 19

README

scf4go

simple config facade for golang

usage

for details see the test examples

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodec     = errors.New("invalid codec name", errors.WithVendor(errVendor), errors.WithCode(-1))
	ErrJSONCodec = errors.New("scf4go basic running mode must import json codec implement", errors.WithVendor(errVendor), errors.WithCode(-1))
)

Errors

Functions

func Register

func Register(codec Codec)

Register .

Types

type Codec

type Codec interface {
	Encode(interface{}) ([]byte, error)
	Decode([]byte, interface{}) error
	Name() string
}

Codec .

func Codecs

func Codecs() []Codec

Codecs get register codec slice

type Config

type Config interface {
	Values
	Close()
	Load(readers ...Reader) error
	Reload() error
	SubConfig(path ...string) Config
	Prefix() []string
}

Config the config facade

func New

func New() Config

New Config create new config object

type Option

type Option func(options *Options)

Option .

func WithCodec

func WithCodec(name string) Option

WithCodec .

type Options

type Options struct {
	Codec string
}

Options .

func NewOptions

func NewOptions(options ...Option) *Options

NewOptions .

type ReadBlock

type ReadBlock struct {
	Data      []byte
	Codec     string
	Timestamp time.Time
}

ReadBlock .

type Reader

type Reader interface {
	Read() ([]*ReadBlock, error)
	Name() string
}

Reader Read the config source object

type Value

type Value interface {
	Bool(def bool) bool
	Int(def int) int
	String(def string) string
	Float64(def float64) float64
	Duration(def time.Duration) time.Duration
	StringSlice(def []string) []string
	StringMap(def map[string]string) map[string]string
	Scan(val interface{}) error
}

Value .

type Values

type Values interface {
	// Retrieve a value
	Get(path ...string) Value
	// Return values as a map
	Map() map[string]interface{}
	// Scan config into a Go type
	Scan(v interface{}) error
}

Values the config values access interface

Directories

Path Synopsis
reader

Jump to

Keyboard shortcuts

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