Skip to content

Commit 1630ae8

Browse files
committed
Bumped v0.8.3
Signed-off-by: Vishal Rana <[email protected]>
1 parent f3c8c98 commit 1630ae8

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependency:
22
go get -u github.com/golang/dep/cmd/dep
3-
dep ensure -update
3+
dep ensure
44

55
test:
66
echo "" > coverage.txt

client.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package labstack
22

33
import (
44
"sync"
5-
"time"
65

76
"github.com/dghubble/sling"
87
glog "github.com/labstack/gommon/log"
@@ -54,12 +53,6 @@ func (c *Client) Cube() (cube *Cube) {
5453
DispatchInterval: 60,
5554
}
5655
cube.resetRequests()
57-
go func() {
58-
d := time.Duration(cube.DispatchInterval) * time.Second
59-
for range time.Tick(d) {
60-
cube.dispatch()
61-
}
62-
}()
6356
return
6457
}
6558

cube.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type (
1919
sling *sling.Sling
2020
requests []*CubeRequest
2121
activeRequests int64
22+
started int64
2223
mutex *sync.RWMutex
2324
logger *log.Logger
2425

@@ -119,6 +120,16 @@ func (c *Cube) dispatch() error {
119120

120121
// Start starts recording an HTTP request.
121122
func (c *Cube) Start(r *http.Request, w http.ResponseWriter) (request *CubeRequest) {
123+
if c.started == 0 {
124+
go func() {
125+
d := time.Duration(c.DispatchInterval) * time.Second
126+
for range time.Tick(d) {
127+
c.dispatch()
128+
}
129+
}()
130+
atomic.AddInt64(&c.started, 1)
131+
}
132+
122133
request = &CubeRequest{
123134
ID: RequestID(r, w),
124135
Time: time.Now(),

0 commit comments

Comments
 (0)