Improve Management startup time (#355)

This commit is contained in:
Misha Bragin 2022-06-06 13:45:59 +02:00 committed by GitHub
parent b96e616844
commit dab146ed87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -165,16 +165,18 @@ func BuildManager(
ctx: context.Background(),
}
// if account has not default account
// we build 'all' group and add all peers into it
// also we create default rule with source an destination
// groups 'all'
// if account has not default group
// we create 'all' group and add all peers into it
// also we create default rule with source as destination
for _, account := range store.GetAllAccounts() {
_, err := account.GetGroupAll()
if err != nil {
am.addAllGroup(account)
if err := store.SaveAccount(account); err != nil {
return nil, err
}
}
}
gocacheClient := gocache.New(CacheExpirationMax, 30*time.Minute)
gocacheStore := cacheStore.NewGoCache(gocacheClient, nil)
@ -640,7 +642,7 @@ func (am *DefaultAccountManager) createAccount(accountId, userId, domain string)
return account, nil
}
// addAllGroup to account object it it doesn't exists
// addAllGroup to account object if it doesn't exists
func (am *DefaultAccountManager) addAllGroup(account *Account) {
if len(account.Groups) == 0 {
allGroup := &Group{