resources: Improve notification system and notify refreshes
Resources can send "refresh" notifications along edges. These messages are sent whenever the upstream (initiating vertex) changes state. When the changed state propagates downstream, it will be paired with a refresh flag which can be queried in the CheckApply method of that resource. Future work will include a stateful refresh tracking mechanism so that if a refresh event is generated and not consumed, it will be saved across an interrupt (shutdown) or a crash so that it can be re-applied on the subsequent run. This is important because the unapplied refresh is a form of hysteresis which needs to be tracked and remembered or we won't be able to determine that the state is wrong! Still to do: * Update the autogrouping code to handle the edge notify properties! * Actually finish the stateful bool code
This commit is contained in:
@@ -83,7 +83,20 @@ func (obj *MyGAPI) Graph() (*pgraph.Graph, error) {
|
||||
v2 := pgraph.NewVertex(f1)
|
||||
g.AddVertex(v2)
|
||||
|
||||
s1 := &resources.SvcRes{
|
||||
BaseRes: resources.BaseRes{
|
||||
Name: "purpleidea",
|
||||
},
|
||||
State: "stopped",
|
||||
}
|
||||
|
||||
v3 := pgraph.NewVertex(s1)
|
||||
g.AddVertex(v3)
|
||||
|
||||
g.AddEdge(v1, v2, pgraph.NewEdge("e1"))
|
||||
e2 := pgraph.NewEdge("e2")
|
||||
e2.Notify = true // send a notification from v2 to v3
|
||||
g.AddEdge(v2, v3, e2)
|
||||
|
||||
//g, err := config.NewGraphFromConfig(obj.data.Hostname, obj.data.EmbdEtcd, obj.data.Noop)
|
||||
return g, nil
|
||||
|
||||
Reference in New Issue
Block a user