trustmaster / goflow

Flow-based and dataflow programming library for Go (golang)
MIT License
1.6k stars 125 forks source link

Explicit shutdown methods #16

Closed trustmaster closed 10 years ago

trustmaster commented 10 years ago

Currently the networks are shut down with the downstream flow: closing an input of a process makes it close its outputs (after it finishes processing current data), closing inputs for the downstream process and so on until all processes in the network are stopped.

Some networks don't have input ports, they are started with IIPs and continue running until the application receives termination signal. Or in some cases the network has to be shut down as soon as possible without knowing about its inputs.

So, 2 new methods are proposed:

I also have a suspicion that the current "downstream shutdown" strategy might cause races in complex graphs with multiple merging branches. So this should be studied and probably alternative strategies should be considered.

trustmaster commented 10 years ago

Eventually this method has been implemented:

Graph.Stop()

It stops a running network by stopping its processes and subnets, but without closing any connections. It makes it possible to stop and replace some parts of network without closing channels and having to recreate and reconnect everything. Also it lets some unfinished tasks to be finished normally.