forked from moby/swarmkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.go
29 lines (26 loc) · 1010 Bytes
/
object.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
package store
import (
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/manager/state"
memdb "github.com/hashicorp/go-memdb"
)
// Object is a generic object that can be handled by the store.
type Object interface {
ID() string // Get ID
Meta() api.Meta // Retrieve metadata
SetMeta(api.Meta) // Set metadata
Copy() Object // Return a copy of this object
EventCreate() state.Event // Return a creation event
EventUpdate() state.Event // Return an update event
EventDelete() state.Event // Return a deletion event
}
// ObjectStoreConfig provides the necessary methods to store a particular object
// type inside MemoryStore.
type ObjectStoreConfig struct {
Name string
Table *memdb.TableSchema
Save func(ReadTx, *api.StoreSnapshot) error
Restore func(Tx, *api.StoreSnapshot) error
ApplyStoreAction func(Tx, *api.StoreAction) error
NewStoreAction func(state.Event) (api.StoreAction, error)
}