-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmodels.go
47 lines (40 loc) · 880 Bytes
/
models.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
package binancewebsocket
import (
"github.com/alexey-ernest/go-binance-websocket/pool"
//"errors"
)
type RawDepth struct {
LastUpdateID int64 `json:"u"`
Bids [][2]string `json:"b"`
Asks [][2]string `json:"a"`
}
type Depth struct {
pool.ReferenceCounter `json:"-"`
RawDepth
}
func (d *Depth) Reset() {
d.Bids = nil
d.Asks = nil
d.LastUpdateID = 0
}
// Used by reference countable pool
func ResetDepth(i interface{}) error {
return nil
// obj, ok := i.(*Depth)
// if !ok {
// return errors.New("illegal object sent to ResetDepth")
// }
// obj.Reset()
// return nil
}
// depth pool
var depthPool = pool.NewReferenceCountedPool(
func(counter pool.ReferenceCounter) pool.ReferenceCountable {
d := new(Depth)
d.ReferenceCounter = counter
return d
}, ResetDepth)
// Method to get new Depth
func AcquireDepth() *Depth {
return depthPool.Get().(*Depth)
}