avoid create a new name generator at each bucket instanciation, it's not that cheap (#1591)
This commit is contained in:
parent
67841d54ee
commit
ff72a3c1c7
2 changed files with 4 additions and 4 deletions
|
@ -9,7 +9,6 @@ import (
|
|||
//"log"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/time/rate"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
"github.com/goombaio/namegenerator"
|
||||
"gopkg.in/tomb.v2"
|
||||
|
||||
//rate "time/rate"
|
||||
|
@ -158,7 +157,7 @@ func FromFactory(bucketFactory BucketFactory) *Leaky {
|
|||
l := &Leaky{
|
||||
Name: bucketFactory.Name,
|
||||
Limiter: limiter,
|
||||
Uuid: namegenerator.NewNameGenerator(time.Now().UTC().UnixNano()).Generate(),
|
||||
Uuid: seed.Generate(),
|
||||
Queue: NewQueue(Qsize),
|
||||
CacheSize: bucketFactory.CacheSize,
|
||||
Out: make(chan *Queue, 1),
|
||||
|
|
|
@ -74,6 +74,9 @@ type BucketFactory struct {
|
|||
wgDumpState *sync.WaitGroup `yaml:"-"`
|
||||
}
|
||||
|
||||
//we use one NameGenerator for all the future buckets
|
||||
var seed namegenerator.Generator = namegenerator.NewNameGenerator(time.Now().UTC().UnixNano())
|
||||
|
||||
func ValidateFactory(bucketFactory *BucketFactory) error {
|
||||
if bucketFactory.Name == "" {
|
||||
return fmt.Errorf("bucket must have name")
|
||||
|
@ -147,8 +150,6 @@ func LoadBuckets(cscfg *csconfig.CrowdsecServiceCfg, files []string, tomb *tomb.
|
|||
response chan types.Event
|
||||
)
|
||||
|
||||
var seed namegenerator.Generator = namegenerator.NewNameGenerator(time.Now().UTC().UnixNano())
|
||||
|
||||
response = make(chan types.Event, 1)
|
||||
for _, f := range files {
|
||||
log.Debugf("Loading '%s'", f)
|
||||
|
|
Loading…
Add table
Reference in a new issue