config

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownTransport means a TransportFactory is missing for a transport.
	ErrUnknownTransport = errors.New("unknown transport")
)

Functions

This section is empty.

Types

type Config

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

Config is the postdog configuration.

func File added in v0.9.4

func File(path string) (*Config, error)

File parses the configuration file at path into a Config.

func Reader added in v0.9.4

func Reader(r io.Reader) (*Config, error)

Reader parses the configuration in r into a Config.

func (*Config) Dog

func (cfg *Config) Dog(ctx context.Context, opts ...Option) (*postdog.Dog, error)

Dog instantiates the *postdog.Dog from the parsed configuration.

For every distinct `transport.use` config value a TransportFactory must be provided. It will return ErrUnknownTransport if a TransportFactory is missing.

func (*Config) Parse

func (cfg *Config) Parse(raw []byte) error

Parse parses the YAML configuration in raw.

func (*Config) Transport

func (cfg *Config) Transport(name string) (tr Transport, ok bool)

Transport returns the transport configuration for the given name, or ok=false if the config doesn't have a transport with that name.

type Option

type Option func(*Config)

Option is an option for the (*Config).Dog() method.

func WithTransportFactory

func WithTransportFactory(use string, factory TransportFactory) Option

WithTransportFactory returns an Option that specifies the TransportFactory for a `transport.use` value.

type Transport

type Transport struct {
	Use    string                 `yaml:"use"`
	Config map[string]interface{} `yaml:"config"`
}

Transport is a transport configuration.

type TransportFactory

type TransportFactory interface {
	Transport(context.Context, map[string]interface{}) (postdog.Transport, error)
}

A TransportFactory accepts the transport-specific configuration and instantiates a transport from that configuration.

Directories

Path Synopsis
Package mock_config is a generated GoMock package.
Package mock_config is a generated GoMock package.

Jump to

Keyboard shortcuts

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