bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/leakybucket/buckets.go (about)

     1  package leakybucket
     2  
     3  import (
     4  	"crypto/sha1"
     5  	"fmt"
     6  	"sync"
     7  )
     8  
     9  // Buckets is the struct used to hold buckets in the context of
    10  // main.go the idea is to have one struct to rule them all
    11  type Buckets struct {
    12  	wgDumpState *sync.WaitGroup
    13  	wgPour      *sync.WaitGroup
    14  	Bucket_map  *sync.Map
    15  }
    16  
    17  // NewBuckets create the Buckets struct
    18  func NewBuckets() *Buckets {
    19  	return &Buckets{
    20  		wgDumpState: &sync.WaitGroup{},
    21  		wgPour:      &sync.WaitGroup{},
    22  		Bucket_map:  &sync.Map{},
    23  	}
    24  }
    25  
    26  func GetKey(bucketCfg BucketFactory, stackkey string) string {
    27  	return fmt.Sprintf("%x", sha1.Sum([]byte(bucketCfg.Filter+stackkey+bucketCfg.Name)))
    28  
    29  }