-
Notifications
You must be signed in to change notification settings - Fork 9
/
option.go
48 lines (41 loc) · 1002 Bytes
/
option.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 pebbleds
import (
"github.com/cockroachdb/pebble"
)
type config struct {
cacheSize int64
db *pebble.DB
pebbleOpts *pebble.Options
}
type Option func(*config)
func getOpts(options []Option) config {
var cfg config
for _, opt := range options {
if opt == nil {
continue
}
opt(&cfg)
}
return cfg
}
// WithCacheSize configures the size of pebble's shared block cache. A value of
// 0 (the default) uses the default cache size.
func WithCacheSize(size int64) Option {
return func(c *config) {
c.cacheSize = size
}
}
// WithPebbleDB is used to configure the Datastore with a custom DB.
func WithPebbleDB(db *pebble.DB) Option {
return func(c *config) {
c.db = db
}
}
// WithPebbleOpts sets any/all configurable values for pebble. If not set, the
// default configuration values are used. Any unspecified value in opts is
// replaced by the default value.
func WithPebbleOpts(opts *pebble.Options) Option {
return func(c *config) {
c.pebbleOpts = opts
}
}