claws

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prod = fx.Module(moduleName,

	fx.Decorate(func(l *zap.Logger) *zap.Logger { return l.Named(moduleName) }),

	fx.Provide(fx.Annotate(
		func(o env.Options) (c Config, err error) {
			o.Prefix = strings.ToUpper(moduleName) + "_"
			return c, env.Parse(&c, o)
		},
		fx.ParamTags(`optional:"true"`))),

	fx.Provide(New),

	fx.Provide(fx.Annotate(func(cfg Config) aws.EndpointResolverWithOptions {
		return aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...any) (ep aws.Endpoint, err error) {
			switch {
			case service == dynamodb.ServiceID && cfg.DynamoEndpoint != nil:
				ep.URL = cfg.DynamoEndpoint.String()
				return ep, err
			default:
				return ep, &aws.EndpointNotFoundError{}
			}
		})
	})),
)

Prod configures the DI for providng database connectivity

Functions

func New

func New(cfg Config, logs *zap.Logger, epresolver aws.EndpointResolverWithOptions) (acfg aws.Config, err error)

New initialize an AWS config to be used to create clients for individual aws services. We would like run this during fx lifecycle phase to provide it with a context because it can block. But too many dependencies would have to wait for it.

Types

type Config

type Config struct {
	// LoadConfigTimeout bounds the time given to config loading
	LoadConfigTimeout time.Duration `env:"LOAD_CONFIG_TIMEOUT" envDefault:"100ms"`
	// DynamoEndpoint allows configuring the dynamodb endpoint for testing because it supports a local version
	DynamoEndpoint *url.URL `env:"DYNAMO_ENDPOINT"`
}

Config configures this package

Jump to

Keyboard shortcuts

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