resources: Implement Send -> Recv
This is a new design idea which I had. Whether it stays around or not is up for debate. For now it's a rough POC. The idea is that any resource can _produce_ data, and any resource can _consume_ data. This is what we call send and recv. By linking the two together, data can be passed directly between resources, which will maximize code re-use, and allow for some interesting logical graphs. For example, you might have an HTTP resource which puts its output in a particular file. This avoids having to overload the HTTP resource with all of the special behaviours of the File resource. For our POC, I implemented a `password` resource which generates a random string which can then be passed to a receiver such as a file. At this point the password resource isn't recommended for sensitive applications because it caches the password as plain text. Still to do: * Statically check all of the type matching before we run the graph * Verify that our autogrouping works correctly around this feature * Verify that appropriate edges exist between send->recv pairs * Label the password as generated instead of storing the plain text * Consider moving password logic from Init() to CheckApply() * Consider combining multiple send values (list?) into a single receiver * Consider intermediary transformation nodes for value combining
This commit is contained in:
@@ -659,6 +659,14 @@ func (g *Graph) Process(v *Vertex) error {
|
||||
}
|
||||
|
||||
obj.SetState(resources.ResStateCheckApply)
|
||||
|
||||
// connect any senders to receivers and detect if values changed
|
||||
if changed, err := obj.SendRecv(obj); err != nil {
|
||||
return errwrap.Wrapf(err, "could not SendRecv in Process")
|
||||
} else if changed {
|
||||
obj.StateOK(false) // invalidate cache
|
||||
}
|
||||
|
||||
// if this fails, don't UpdateTimestamp()
|
||||
checkok, err := obj.CheckApply(!obj.Meta().Noop)
|
||||
if checkok && err != nil { // should never return this way
|
||||
|
||||
Reference in New Issue
Block a user