-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.go
51 lines (41 loc) · 1.03 KB
/
types.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
49
50
51
package seer
import (
"sync"
"github.com/spf13/afero"
"gopkg.in/yaml.v3"
)
type Document interface{}
type Seer struct {
fs afero.Fs
lock sync.Mutex
documents map[string]*yaml.Node
}
const (
opTypeGet = 1
opTypeCreateDocument = 2
opTypeCreateFolder = 3 // TODO: Either implement or delete
opTypeSet = 16
opTypeGetOrCreate = 42
)
type op struct {
opType int
name string
value interface{}
handler opHandler
}
type yamlNode struct {
parent *yaml.Node // prant
prev *yaml.Node // previous -- genrally contains name
this *yaml.Node // node with data
}
type opHandler func(this op, node *Query, path []string /*returned by previous op*/, value *yamlNode /* value passed by parent*/) ( /*path*/ []string /*value*/, *yamlNode, error)
type Query struct {
seer *Seer
write bool // set to true by Commit() --- set to false by Value()
requestedPath []string // is built by the Gets
ops []op
errors []error
}
type Batch struct {
queries []*Query
}