-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderqueue_pool.go
38 lines (30 loc) · 984 Bytes
/
orderqueue_pool.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
package orderbook
import (
"context"
pool "github.com/jolestar/go-commons-pool"
)
// OrderQueueObjectFactory ...
type OrderQueueObjectFactory struct{}
// MakeObject ...
func (of *OrderQueueObjectFactory) MakeObject(ctx context.Context) (*pool.PooledObject, error) {
return &pool.PooledObject{
Object: NewOrderQueue(ctx.Value("order_queue_size").(uint64)),
}, nil
}
// DestroyObject ...
func (of *OrderQueueObjectFactory) DestroyObject(ctx context.Context, object *pool.PooledObject) error {
return nil
}
// ValidateObject ...
func (of *OrderQueueObjectFactory) ValidateObject(ctx context.Context, object *pool.PooledObject) bool {
return true
}
// ActivateObject ...
func (of *OrderQueueObjectFactory) ActivateObject(ctx context.Context, object *pool.PooledObject) error {
object.Object.(*OrderQueue).Reset()
return nil
}
// PassivateObject ...
func (of *OrderQueueObjectFactory) PassivateObject(ctx context.Context, object *pool.PooledObject) error {
return nil
}