ipld-eth-server/vendor/gopkg.in/DataDog/dd-trace-go.v1/contrib/globalsign/mgo/option.go

33 lines
691 B
Go
Raw Normal View History

2018-09-04 16:35:38 +00:00
package mgo
import "context"
type mongoConfig struct {
ctx context.Context
serviceName string
tags map[string]string
}
func defaults(cfg *mongoConfig) {
cfg.serviceName = "mongodb"
cfg.ctx = context.Background()
cfg.tags = make(map[string]string)
}
// DialOption represents an option that can be passed to Dial
type DialOption func(*mongoConfig)
// WithServiceName sets the service name for a given MongoDB context.
func WithServiceName(name string) DialOption {
return func(cfg *mongoConfig) {
cfg.serviceName = name
}
}
// WithContext sets the context.
func WithContext(ctx context.Context) DialOption {
return func(cfg *mongoConfig) {
cfg.ctx = ctx
}
}