A simple implementation of Erlang/OTP's Supervisor pattern for Go. A Supervisor is a simple mechanism for improving fault-tolerance of concurrent processes; minimising interruptions in the event of any errors.
I love the idea of Erlang/OTP's concurrency model, and specifically Supervision Trees. ¯\(ツ)/¯
It's also a pattern I've found myself implementing in the past, and one that I've recently written about. See the original blog post.
Please see the automatically generated go documentation in addition to the examples directory.
- Workers - or
Supervisables
- must ensure that they capture panics viarecover()
and that they close the provided channel before closing. This can be done in one single deferred function. See the examples for more information.
See the Makefile
for tasks; but there's tests, linting, and docs.
-
If I get around to it I'll actually make it tree like; at the moment there's the concept of a
Supervisor
which is likely enough for most pipeline. However nesting Supervisors to make a multi-layer tree will requiring wrapping the individual structs in a function that adheres toSupervisable
. -
Notifications that a Supervisor has completed. This will most likely be done via a
sync.WaitGroup
; and perhaps some hacking around the user providedsync.WaitGroup
.
This repository is distributed under the terms of the MIT license; if - for some unknown reason - you wish to use this, then you're free to do as you like as per the terms of that license, with the caveat that the license must be distributed in conjunction with this codebase. Additionally - no warranty - if this messes yo' shit up then do not blame me.
See ./LICENSE.