forked from linxGnu/grocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathratelimiter.go
More file actions
31 lines (26 loc) · 798 Bytes
/
ratelimiter.go
File metadata and controls
31 lines (26 loc) · 798 Bytes
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
package grocksdb
// #include <stdlib.h>
// #include "rocksdb/c.h"
import "C"
// RateLimiter is used to control write rate of flush and
// compaction.
type RateLimiter struct {
c *C.rocksdb_ratelimiter_t
}
// NewRateLimiter creates a default RateLimiter object.
func NewRateLimiter(rateBytesPerSec, refillPeriodMicros int64, fairness int32) *RateLimiter {
return NewNativeRateLimiter(C.rocksdb_ratelimiter_create(
C.int64_t(rateBytesPerSec),
C.int64_t(refillPeriodMicros),
C.int32_t(fairness),
))
}
// NewNativeRateLimiter creates a native RateLimiter object.
func NewNativeRateLimiter(c *C.rocksdb_ratelimiter_t) *RateLimiter {
return &RateLimiter{c}
}
// Destroy deallocates the RateLimiter object.
func (r *RateLimiter) Destroy() {
C.rocksdb_ratelimiter_destroy(r.c)
r.c = nil
}