Skip to content

Commit

Permalink
fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Sep 5, 2018
1 parent 09c2e15 commit 3986370
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions client/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

// Tracker a tracker keeps track of keep alive intervals
// A Tracker keeps track of keep alive intervals.
type Tracker struct {
sync.RWMutex

Expand All @@ -14,47 +14,47 @@ type Tracker struct {
timeout time.Duration
}

// NewTracker returns a new tracker
// NewTracker returns a new tracker.
func NewTracker(timeout time.Duration) *Tracker {
return &Tracker{
last: time.Now(),
timeout: timeout,
}
}

// Reset updates the tracker
// Reset will reset the tracker.
func (t *Tracker) Reset() {
t.Lock()
defer t.Unlock()

t.last = time.Now()
}

// Window returns the current time window
// Window returns the time until a new ping should be sent.
func (t *Tracker) Window() time.Duration {
t.RLock()
defer t.RUnlock()

return t.timeout - time.Since(t.last)
}

// Ping mark ping
// Ping marks a ping.
func (t *Tracker) Ping() {
t.Lock()
defer t.Unlock()

t.pings++
}

// Pong mark pong
// Pong marks a pong.
func (t *Tracker) Pong() {
t.Lock()
defer t.Unlock()

t.pings--
}

// Pending returns if pings are pending
// Pending returns if pings are pending.
func (t *Tracker) Pending() bool {
t.RLock()
defer t.RUnlock()
Expand Down

0 comments on commit 3986370

Please sign in to comment.