-
Notifications
You must be signed in to change notification settings - Fork 0
/
descriptor.go
43 lines (37 loc) · 1.01 KB
/
descriptor.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
package persistentmemorydriver
import (
"fmt"
"github.com/apiles/unikv"
)
// DriverContext defines the driver context
type DriverContext struct {
Filename string `json:"filename"`
Filemode int `json:"filemode"`
CommitWhenPut bool `json:"commit_when_put"`
LoadWhenGet bool `json:"load_when_get"`
}
// Constructor constructs new memory drivers
func Constructor(prefix string, ctx unikv.DriverContextRaw) (unikv.Driver, error) {
context := &DriverContext{
Filename: DefaultFilename,
Filemode: DefaultFilemode,
CommitWhenPut: true,
LoadWhenGet: false,
}
err := unikv.DriverLoadContext(ctx, context)
if err != nil {
return nil, err
}
return NewDriver(prefix, context)
}
// Descriptor describes memory driver
var Descriptor = &unikv.DriverDescriptor{
Name: "persistent-memory",
Constructor: Constructor,
}
func init() {
if unikv.Version != Version {
panic(fmt.Errorf("Unmatched version with unikv, expected APIv%d", Version))
}
unikv.RegisterDriver(Descriptor)
}