48 lines
816 B
Go
48 lines
816 B
Go
package eventmod
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"videoweb/pub/mongos"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
)
|
|
|
|
var db *mongos.Collection
|
|
|
|
func Init(ctx context.Context) {
|
|
db = mongos.Shop.Coll(TN.Event)
|
|
indexes := []mongo.IndexModel{
|
|
{
|
|
Keys: bson.D{
|
|
{Key: FN.Event.Status, Value: 1},
|
|
},
|
|
},
|
|
{
|
|
Keys: bson.D{
|
|
{Key: FN.Event.EventType, Value: 1},
|
|
},
|
|
},
|
|
{
|
|
Keys: bson.D{
|
|
{Key: FN.Event.EventId, Value: 1},
|
|
},
|
|
},
|
|
{
|
|
Keys: bson.D{
|
|
{Key: FN.Event.Status, Value: 1},
|
|
{Key: FN.Event.RetryCount, Value: 1},
|
|
},
|
|
},
|
|
{
|
|
Keys: bson.D{
|
|
{Key: FN.Event.CreatedAt, Value: -1},
|
|
},
|
|
},
|
|
}
|
|
if _, err := db.CreateIndex(ctx, indexes); err != nil {
|
|
panic(fmt.Sprintf("(eventmod:Init) Create Event Index failed! err:%+v:", err))
|
|
}
|
|
}
|