blog

package
v0.0.0-...-e46c3b8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(func(lc fx.Lifecycle, logger *zap.Logger, validate *validator.Validate) (service.Service, error) {
		opts := options.Client().ApplyURI(env.Get(dbURIKey))
		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
		defer cancel()
		client, err := mongo.Connect(ctx, opts)
		if err != nil {
			return nil, err
		}
		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				return client.Ping(ctx, nil)
			},
			OnStop: client.Disconnect,
		})
		coll := client.Database(env.Get(dbNameKey)).Collection(env.Get(collectionKey))
		return service.Use(repo.UseCollection(coll), logger, validate), nil
	}),
	fx.Invoke(data.RegisterValidators),
	fx.Invoke(routes.Register),
)

Module bundles fx.Options for the feed Fx Module.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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