mirror of https://github.com/status-im/consul.git
consul: Move notification group from MDBTable into the state store
This commit is contained in:
parent
67a7d25e1c
commit
420417861a
|
@ -34,11 +34,6 @@ type MDBTable struct {
|
|||
Encoder func(interface{}) []byte
|
||||
Decoder func([]byte) interface{}
|
||||
|
||||
// NotifyGroup is created in init, it can be used to
|
||||
// watch a table for changes. It is not invoked internally,
|
||||
// but can be used by clients of the table.
|
||||
NotifyGroup *NotifyGroup
|
||||
|
||||
// Last used rowID
|
||||
lastRowID uint64
|
||||
}
|
||||
|
@ -104,9 +99,6 @@ func (t *MDBTable) Init() error {
|
|||
return fmt.Errorf("Missing table indexes")
|
||||
}
|
||||
|
||||
// Create the notify group
|
||||
t.NotifyGroup = &NotifyGroup{}
|
||||
|
||||
// Ensure we have a unique id index
|
||||
id, ok := t.Indexes["id"]
|
||||
if !ok {
|
||||
|
|
|
@ -29,6 +29,7 @@ type StateStore struct {
|
|||
serviceTable *MDBTable
|
||||
checkTable *MDBTable
|
||||
tables MDBTables
|
||||
watch map[*MDBTable]*NotifyGroup
|
||||
}
|
||||
|
||||
// StateSnapshot is used to provide a point-in-time snapshot
|
||||
|
@ -60,8 +61,9 @@ func NewStateStore() (*StateStore, error) {
|
|||
}
|
||||
|
||||
s := &StateStore{
|
||||
path: path,
|
||||
env: env,
|
||||
path: path,
|
||||
env: env,
|
||||
watch: make(map[*MDBTable]*NotifyGroup),
|
||||
}
|
||||
|
||||
// Ensure we can initialize
|
||||
|
@ -184,6 +186,9 @@ func (s *StateStore) initialize() error {
|
|||
if err := table.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Setup a notification group per table
|
||||
s.watch[table] = &NotifyGroup{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue