config

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, name string) interface{}

FromContext extracts config from a context

func RegisterConfigCreator

func RegisterConfigCreator(name string, creator Creator)

RegisterConfigCreator registers a config struct for parsing

func RegisterDynamicConfigCreator

func RegisterDynamicConfigCreator(name string, creator DynamicCreator)

func WithConfig

func WithConfig(ctx context.Context, name string, cfg interface{}) context.Context

func WithJSONConfig

func WithJSONConfig(ctx context.Context, data []byte) (context.Context, error)

func WithJSONDynamicConfig

func WithJSONDynamicConfig(ctx context.Context, data []byte) (context.Context, error)

func WithYAMLConfig

func WithYAMLConfig(ctx context.Context, data []byte) (context.Context, error)

func WithYAMLDynamicConfig

func WithYAMLDynamicConfig(ctx context.Context, data []byte) (context.Context, error)

Types

type Creator

type Creator func() interface{}

Creator creates default config struct for a module

type DynamicConfig

type DynamicConfig interface {
	Init() error
	Priority() int
}

func FromContextDynamic

func FromContextDynamic(ctx context.Context, name string) DynamicConfig

type DynamicConfigs

type DynamicConfigs struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDynamicConfigs

func NewDynamicConfigs() *DynamicConfigs

func (*DynamicConfigs) Get

func (dconfig *DynamicConfigs) Get(name string) DynamicConfig

func (*DynamicConfigs) ReloadHandler

func (dconfig *DynamicConfigs) ReloadHandler(query url.Values) error

type DynamicCreator

type DynamicCreator func() DynamicConfig

type DynamicCreators

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

func (DynamicCreators) Len

func (dynamicCreators DynamicCreators) Len() int

func (DynamicCreators) Less

func (dynamicCreators DynamicCreators) Less(i, j int) bool

func (DynamicCreators) Swap

func (dynamicCreators DynamicCreators) Swap(i, j int)

Jump to

Keyboard shortcuts

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