Skip to content

Commit e97e978

Browse files
committed
Exposed Cube#Dispatch()
Signed-off-by: Vishal Rana <[email protected]>
1 parent e564dd0 commit e97e978

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cube.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ type (
5858
UserAgent string `json:"user_agent"`
5959
Active int64 `json:"active"`
6060
// TODO: CPU, Uptime, Memory
61+
Language string `json:"language"`
62+
Error string `json:"error"`
63+
StackTrace string `json:"stack_trace"`
6164
}
6265

6366
// CubeError defines the cube error.
@@ -95,7 +98,8 @@ func (c *Cube) requestsLength() int {
9598
return len(c.requests)
9699
}
97100

98-
func (c *Cube) dispatch() error {
101+
// Dispatch dispatches the requests batch.
102+
func (c *Cube) Dispatch() error {
99103
if len(c.requests) == 0 {
100104
return nil
101105
}
@@ -120,6 +124,7 @@ func (c *Cube) Start(r *http.Request, w http.ResponseWriter) (request *CubeReque
120124
Method: r.Method,
121125
UserAgent: r.UserAgent(),
122126
RemoteIP: RealIP(r),
127+
Language: "Go",
123128
}
124129
request.ClientID = request.RemoteIP
125130
atomic.AddInt64(&c.activeRequests, 1)
@@ -147,7 +152,7 @@ func (c *Cube) Stop(r *CubeRequest, status int, size int64) {
147152
// Dispatch batch
148153
if c.requestsLength() >= c.BatchSize {
149154
go func() {
150-
if err := c.dispatch(); err != nil {
155+
if err := c.Dispatch(); err != nil {
151156
c.logger.Error(err)
152157
}
153158
c.resetRequests()

0 commit comments

Comments
 (0)