summaryrefslogtreecommitdiff
path: root/vendor/github.com/hpcloud/tail/ratelimiter/memory.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-02-06 09:07:51 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-09 15:27:52 +0000
commitfa9658cbfaa94fd5d0425041404e498c01db1aa3 (patch)
tree3cacae5b613692387780209a5d41b10c2edc0940 /vendor/github.com/hpcloud/tail/ratelimiter/memory.go
parent75914199f331a10eb7ed44de68c738515bdd5b2d (diff)
downloadpodman-fa9658cbfaa94fd5d0425041404e498c01db1aa3.tar.gz
podman-fa9658cbfaa94fd5d0425041404e498c01db1aa3.tar.bz2
podman-fa9658cbfaa94fd5d0425041404e498c01db1aa3.zip
podman logs: fix tailing
Fix issues with tailing of container logs as described in issue #16. Also add in the ability to use a duration or known time stamp formats for the --since flag. Signed-off-by: baude <bbaude@redhat.com> Closes: #317 Approved by: mheon
Diffstat (limited to 'vendor/github.com/hpcloud/tail/ratelimiter/memory.go')
-rw-r--r--vendor/github.com/hpcloud/tail/ratelimiter/memory.go58
1 files changed, 0 insertions, 58 deletions
diff --git a/vendor/github.com/hpcloud/tail/ratelimiter/memory.go b/vendor/github.com/hpcloud/tail/ratelimiter/memory.go
deleted file mode 100644
index 8f6a5784a..000000000
--- a/vendor/github.com/hpcloud/tail/ratelimiter/memory.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package ratelimiter
-
-import (
- "errors"
- "time"
-)
-
-const GC_SIZE int = 100
-
-type Memory struct {
- store map[string]LeakyBucket
- lastGCCollected time.Time
-}
-
-func NewMemory() *Memory {
- m := new(Memory)
- m.store = make(map[string]LeakyBucket)
- m.lastGCCollected = time.Now()
- return m
-}
-
-func (m *Memory) GetBucketFor(key string) (*LeakyBucket, error) {
-
- bucket, ok := m.store[key]
- if !ok {
- return nil, errors.New("miss")
- }
-
- return &bucket, nil
-}
-
-func (m *Memory) SetBucketFor(key string, bucket LeakyBucket) error {
-
- if len(m.store) > GC_SIZE {
- m.GarbageCollect()
- }
-
- m.store[key] = bucket
-
- return nil
-}
-
-func (m *Memory) GarbageCollect() {
- now := time.Now()
-
- // rate limit GC to once per minute
- if now.Add(60*time.Second).Unix() > m.lastGCCollected.Unix() {
-
- for key, bucket := range m.store {
- // if the bucket is drained, then GC
- if bucket.DrainedAt().Unix() > now.Unix() {
- delete(m.store, key)
- }
- }
-
- m.lastGCCollected = now
- }
-}