Documentation ¶
Overview ¶
Package otmongo provides mongo client with opentracing. For documentation about redis usage, see https://pkg.go.dev/go.mongodb.org/mongo-driver
Integration ¶
package otmongo exports the configuration in the following format:
mongo: default: uri:
Add the mongo dependency to core:
var c *core.C = core.New() c.Provide(otmongo.Providers())
Then you can invoke redis from the application.
c.Invoke(func(client *mongo.Client) { client.Connect(context.Background()) })
Sometimes there are valid reasons to connect to more than one mongo server. Inject otmongo.Maker to factory a *mongo.Client with a specific configuration entry.
c.Invoke(function(maker otmongo.Maker) { client, err := maker.Make("default") // do something with client })
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMonitor ¶
func NewMonitor(tracer opentracing.Tracer) *event.CommandMonitor
NewMonitor creates a new mongodb event CommandMonitor.
func Providers ¶ added in v0.2.0
Providers returns a set of dependency providers. It includes the Maker, the default mongo.Client and exported configs.
Depends On: log.Logger contract.ConfigAccessor MongoConfigInterceptor `optional:"true"` opentracing.Tracer `optional:"true"` Provides: Factory Maker *mongo.Client
Types ¶
type Factory ¶
Factory is a *di.Factory that creates *mongo.Client using a specific configuration entry.
type MongoConfigInterceptor ¶ added in v0.2.0
type MongoConfigInterceptor func(name string, clientOptions *options.ClientOptions)
MongoConfigInterceptor is an injection type hint that allows user to make last minute modification to mongo configuration. This is useful when some configuration cannot be easily expressed in a text form. For example, the options.ContextDialer.