data-preservation-programs / singularity

Tool for onboarding data to the Filecoin Network
Other
18 stars 16 forks source link

Consolidate service channels #415

Closed gammazero closed 1 year ago

gammazero commented 1 year ago

What is the problem you're trying to solve?

When services start, each service worker goroutine returns a slice of "done" channels to signal when parts of the service are done, and a "fail" channel to indicate if the service has exited with an error. This requires watching all of these, for each worker, and greatly complicates monitoring and shutdown.

Describe the workaround you currently have

I don't have any workaround

Describe the feature you'd like

This should be simplified by having each worker return a single error channel. If the worker exits due to an error, then the error is written to that channel. If the worker exits for a non-error reason, then the channel is closed (returning nil error). The controlling go routine does not care about which service components have finished, only that the service is done and whether this is because of an error or not.

Alternatively, the same error channel can be shared by all workers, and each worker will write its error or nil to the channel when done. This means that the controlling goroutine only needs to wait for all workers to post their exit status on the one shared error channel.

Additional context

No response