ipld-eth-server/vendor/gopkg.in/DataDog/dd-trace-go.v1/contrib/globalsign/mgo/option.go
2018-09-11 16:30:29 -05:00

33 lines
691 B
Go

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
}
}