forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathstats.go
48 lines (38 loc) · 1.11 KB
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package crud
import (
"context"
"github.com/vmihailenco/msgpack/v5"
"github.com/tarantool/go-tarantool/v2"
)
// StatsRequest helps you to create request object to call `crud.stats`
// for execution by a Connection.
type StatsRequest struct {
baseRequest
space OptString
}
// MakeStatsRequest returns a new empty StatsRequest.
func MakeStatsRequest() StatsRequest {
req := StatsRequest{}
req.impl = newCall("crud.stats")
return req
}
// Space sets the space name for the StatsRequest request.
// Note: default value is nil.
func (req StatsRequest) Space(space string) StatsRequest {
req.space = MakeOptString(space)
return req
}
// Body fills an encoder with the call request body.
func (req StatsRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error {
if value, ok := req.space.Get(); ok {
req.impl = req.impl.Args([]interface{}{value})
} else {
req.impl = req.impl.Args([]interface{}{})
}
return req.impl.Body(res, enc)
}
// Context sets a passed context to CRUD request.
func (req StatsRequest) Context(ctx context.Context) StatsRequest {
req.impl = req.impl.Context(ctx)
return req
}