Skip to content

Simple Go implementation of Erlang/OTP's Supervision Trees

License

Notifications You must be signed in to change notification settings

FergusInLondon/go-supervise

Repository files navigation

Go Supervise Go Report Card Github Workflow Go Reference

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.

Example

Why?

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.

Usage

Please see the automatically generated go documentation in addition to the examples directory.

NOTE

  • Workers - or Supervisables - must ensure that they capture panics via recover() and that they close the provided channel before closing. This can be done in one single deferred function. See the examples for more information.

Development

See the Makefile for tasks; but there's tests, linting, and docs.

To Do...?

  • 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 to Supervisable.

  • Notifications that a Supervisor has completed. This will most likely be done via a sync.WaitGroup; and perhaps some hacking around the user provided sync.WaitGroup.

License

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.

About

Simple Go implementation of Erlang/OTP's Supervision Trees

Resources

License

Stars

Watchers

Forks

Packages

No packages published