const ( GC_SIZE int = 100 GC_PERIOD time.Duration = 60 * time.Second )
type LeakyBucket struct { Size uint16 Fill float64 LeakInterval time.Duration // time.Duration for 1 unit of size to leak Lastupdate time.Time Now func() time.Time }
func NewLeakyBucket(size uint16, leakInterval time.Duration) *LeakyBucket
func (b *LeakyBucket) DrainedAt() time.Time
The time at which this bucket will be completely drained
func (b *LeakyBucket) Pour(amount uint16) bool
func (b *LeakyBucket) Serialise() *LeakyBucketSer
func (b *LeakyBucket) TimeSinceLastUpdate() time.Duration
func (b *LeakyBucket) TimeToDrain() time.Duration
The duration until this bucket is completely drained
type LeakyBucketSer struct { Size uint16 Fill float64 LeakInterval time.Duration // time.Duration for 1 unit of size to leak Lastupdate time.Time }
func (b *LeakyBucketSer) DeSerialise() *LeakyBucket
type Memory struct {
// contains filtered or unexported fields
}
func NewMemory() *Memory
func (m *Memory) GarbageCollect()
func (m *Memory) GetBucketFor(key string) (*LeakyBucket, error)
func (m *Memory) SetBucketFor(key string, bucket LeakyBucket) error
type Storage interface { GetBucketFor(string) (*LeakyBucket, error) SetBucketFor(string, LeakyBucket) error }