Compare commits
2 Commits
59b0a975f7
...
7e7d023252
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e7d023252 | |||
| f7ff7ae13b |
@ -131,7 +131,7 @@ func init() {
|
||||
logger.Println("metrics are going to be generated for houston")
|
||||
go mc.metricWriter()
|
||||
NewMetric = newMetricImpl
|
||||
ConcurrentUser = NewMetric(MetricGuage, "concurrent_user", "concurrent user count", nil)
|
||||
ConcurrentUser = NewMetric(MetricGuage, "concurrent_user", "concurrent user count", map[string]string{"location": "lobby"})
|
||||
} else {
|
||||
logger.Println("metrics are NOT going to be generated. parent is not houston :", filename, string(fn))
|
||||
}
|
||||
|
||||
14
mongo.go
14
mongo.go
@ -456,7 +456,7 @@ IndexSearchLabel:
|
||||
return err
|
||||
}
|
||||
|
||||
func (mc MongoClient) makeIndicesWithOption(coll CollectionName, indices map[string]bson.D, option *options.IndexOptions) error {
|
||||
func (mc MongoClient) makeIndicesWithOption(coll CollectionName, indices map[string]bson.D, opts ...*options.IndexOptions) error {
|
||||
collection := mc.Collection(coll)
|
||||
cursor, err := collection.Indexes().List(context.Background(), options.ListIndexes().SetMaxTime(time.Second))
|
||||
if err != nil {
|
||||
@ -484,12 +484,12 @@ func (mc MongoClient) makeIndicesWithOption(coll CollectionName, indices map[str
|
||||
if len(v) == 1 {
|
||||
mod = mongo.IndexModel{
|
||||
Keys: primitive.M{v[0].Key: v[0].Value},
|
||||
Options: options.MergeIndexOptions(options.Index().SetName(name), option),
|
||||
Options: options.MergeIndexOptions(append(opts, options.Index().SetName(name))...),
|
||||
}
|
||||
} else {
|
||||
mod = mongo.IndexModel{
|
||||
Keys: indices[name],
|
||||
Options: options.MergeIndexOptions(options.Index().SetName(name), option),
|
||||
Options: options.MergeIndexOptions(append(opts, options.Index().SetName(name))...),
|
||||
}
|
||||
}
|
||||
|
||||
@ -502,10 +502,10 @@ func (mc MongoClient) makeIndicesWithOption(coll CollectionName, indices map[str
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mc MongoClient) MakeUniqueIndices(coll CollectionName, indices map[string]bson.D) error {
|
||||
return mc.makeIndicesWithOption(coll, indices, options.Index().SetUnique(true))
|
||||
func (mc MongoClient) MakeUniqueIndices(coll CollectionName, indices map[string]bson.D, opts ...*options.IndexOptions) error {
|
||||
return mc.makeIndicesWithOption(coll, indices, append(opts, options.Index().SetUnique(true))...)
|
||||
}
|
||||
|
||||
func (mc MongoClient) MakeIndices(coll CollectionName, indices map[string]bson.D) error {
|
||||
return mc.makeIndicesWithOption(coll, indices, options.Index())
|
||||
func (mc MongoClient) MakeIndices(coll CollectionName, indices map[string]bson.D, opts ...*options.IndexOptions) error {
|
||||
return mc.makeIndicesWithOption(coll, indices, opts...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user