Compare commits

...

2 Commits

Author SHA1 Message Date
7e7d023252 인덱스 옵션 인자로 받음 2023-11-26 15:46:34 +09:00
f7ff7ae13b concurrent 메트릭에 location 레이블 추가 2023-11-26 15:46:22 +09:00
2 changed files with 8 additions and 8 deletions

View File

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

View File

@ -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...)
}