config

package
v1.74.7 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Unlicense Imports: 22 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Module for fx.
	Module = fx.Options(ConfiguratorModule, UnmarshalModule, ConfigModule, WatchModule)

	// ConfiguratorModule for fx.
	ConfiguratorModule = fx.Provide(NewConfigurator)

	// UnmarshalModule for fx.
	UnmarshalModule = fx.Invoke(UnmarshalFromFile)

	// WatchModule for fx.
	WatchModule = fx.Options(
		fx.Invoke(Watch),
		fx.Provide(NewWaitTime),
	)

	// ConfigModule for fx.
	ConfigModule = fx.Options(
		fx.Provide(redisConfig), fx.Provide(ristrettoConfig),
		fx.Provide(auth0Config),
		fx.Provide(pgConfig),
		fx.Provide(opentracingConfig),
		fx.Provide(transportConfig),
		fx.Provide(grpcConfig),
		fx.Provide(httpConfig),
		fx.Provide(nsqConfig),
	)
)

Functions

func File added in v1.41.0

func File() string

File config location.

func FileFromEnv added in v1.43.0

func FileFromEnv(env string) string

FileFromEnv location.

func MarshalToBytes added in v1.44.0

func MarshalToBytes(cfg Map) ([]byte, error)

MarshalToBytes the map.

func ReadFile added in v1.41.0

func ReadFile() ([]byte, error)

ReadFile from config location.

func ReadFileFromEnv added in v1.62.0

func ReadFileFromEnv(env string) ([]byte, error)

ReadFileFromEnv variable of config location.

func UnmarshalFromBytes added in v1.44.0

func UnmarshalFromBytes(bytes []byte, cfg Map) error

UnmarshalFromBytes to map.

func UnmarshalFromFile added in v1.44.0

func UnmarshalFromFile(cfg Configurator) error

UnmarshalFromFile to config.

func Watch added in v1.60.0

func Watch(params WatchParams) error

Watch the configuration. If it changes terminate the application.

func WriteFileToEnv added in v1.43.0

func WriteFileToEnv(env string, data []byte) error

WriteFileToEnv location.

Types

type Config

type Config struct {
	Cache     cache.Config     `yaml:"cache"`
	Security  security.Config  `yaml:"security"`
	SQL       sql.Config       `yaml:"sql"`
	Trace     trace.Config     `yaml:"trace"`
	Transport transport.Config `yaml:"transport"`
}

Config for the service.

func (*Config) Auth0Config

func (cfg *Config) Auth0Config() *auth0.Config

func (*Config) GRPCConfig

func (cfg *Config) GRPCConfig() *grpc.Config

func (*Config) HTTPConfig

func (cfg *Config) HTTPConfig() *http.Config

func (*Config) NSQConfig

func (cfg *Config) NSQConfig() *nsq.Config

func (*Config) OpentracingConfig added in v1.64.0

func (cfg *Config) OpentracingConfig() *opentracing.Config

func (*Config) PGConfig

func (cfg *Config) PGConfig() *pg.Config

func (*Config) RedisConfig

func (cfg *Config) RedisConfig() *redis.Config

func (*Config) RistrettoConfig

func (cfg *Config) RistrettoConfig() *ristretto.Config

func (*Config) TransportConfig added in v1.70.0

func (cfg *Config) TransportConfig() *transport.Config

type Configurator

type Configurator interface {
	RedisConfig() *redis.Config
	RistrettoConfig() *ristretto.Config
	Auth0Config() *auth0.Config
	PGConfig() *pg.Config
	OpentracingConfig() *opentracing.Config
	TransportConfig() *transport.Config
	GRPCConfig() *grpc.Config
	HTTPConfig() *http.Config
	NSQConfig() *nsq.Config
}

Configurator for config.

func NewConfigurator

func NewConfigurator() Configurator

NewConfigurator for config.

type Map added in v1.44.0

type Map map[string]any

Map for config.

func (Map) Map added in v1.44.0

func (m Map) Map(key string) Map

Map at the key.

type WaitTime added in v1.71.0

type WaitTime time.Duration

WaitTime for shutting down.

func NewWaitTime added in v1.71.0

func NewWaitTime() WaitTime

NewWaitTime for shutting down.

type WatchParams added in v1.60.0

type WatchParams struct {
	fx.In

	Lifecycle  fx.Lifecycle
	Shutdowner fx.Shutdowner
	Logger     *zap.Logger
	WaitTime   WaitTime
	Config     Configurator
}

WatchParams for config.

type Watcher added in v1.71.0

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

Watcher of config changes.

func NewWatcher added in v1.71.0

func NewWatcher(params WatchParams) *Watcher

NewWatcher of config changes.

func (*Watcher) Start added in v1.71.0

func (w *Watcher) Start() error

Start watching.

func (*Watcher) Stop added in v1.71.0

func (w *Watcher) Stop() error

Stop watching.

Jump to

Keyboard shortcuts

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