block collection 에 account를 복수로 저장
This commit is contained in:
@ -148,8 +148,6 @@ type Maingate struct {
|
||||
//services servicelist
|
||||
serviceptr unsafe.Pointer
|
||||
admins unsafe.Pointer
|
||||
wl memberContainerPtr[string, *whitelistmember]
|
||||
bl memberContainerPtr[primitive.ObjectID, *blockinfo]
|
||||
|
||||
tokenEndpoints map[string]string
|
||||
authorizationEndpoints map[string]string
|
||||
@ -345,7 +343,15 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
||||
mg.mongoClient.DropIndex(CollectionBlock, "codeaccid")
|
||||
}
|
||||
|
||||
if err = mg.mongoClient.MakeExpireIndex(CollectionBlock, int32(3)); err != nil {
|
||||
if _, err := mg.mongoClient.Collection(CollectionBlock).Indexes().DropOne(context, "_ts_1"); err == nil {
|
||||
// 인덱스가 방금 지워졌다.
|
||||
// 전체 document 제거
|
||||
logger.Println(mg.mongoClient.Collection(CollectionBlock).Drop(context))
|
||||
}
|
||||
|
||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionBlock, map[string]bson.D{
|
||||
"accidend": {{Key: "accid", Value: 1}, {Key: "end", Value: 1}},
|
||||
}); err != nil {
|
||||
return logger.ErrorWithCallStack(err)
|
||||
}
|
||||
|
||||
@ -412,23 +418,6 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
var whites []*whitelistmember
|
||||
if err := mg.mongoClient.AllAs(CollectionWhitelist, &whites, options.Find().SetReturnKey(false)); err != nil {
|
||||
return logger.ErrorWithCallStack(err)
|
||||
}
|
||||
mg.wl.init(whites)
|
||||
|
||||
var blocks []*blockinfo
|
||||
if err := mg.mongoClient.AllAs(CollectionBlock, &blocks); err != nil {
|
||||
return logger.ErrorWithCallStack(err)
|
||||
}
|
||||
|
||||
logger.Println("allblocks :", blocks)
|
||||
mg.bl.init(blocks)
|
||||
|
||||
go mg.wl.watchCollection(context, CollectionWhitelist, mg.mongoClient)
|
||||
go mg.bl.watchCollection(context, CollectionBlock, mg.mongoClient)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user