Refactor subsystem package

This commit is contained in:
Patrick Pacher 2020-09-21 15:31:21 +02:00
parent 511cb22759
commit 1b55c73559
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D
8 changed files with 393 additions and 278 deletions

View file

@ -1,18 +1,28 @@
/*
Package modules provides a full module and task management ecosystem to cleanly put all big and small moving parts of a service together.
Modules are started in a multi-stage process and may depend on other modules:
- Go's init(): register flags
- prep: check flags, register config variables
- start: start actual work, access config
- stop: gracefully shut down
Workers: A simple function that is run by the module while catching panics and reporting them. Ideal for long running (possibly) idle goroutines. Can be automatically restarted if execution ends with an error.
Tasks: Functions that take somewhere between a couple seconds and a couple minutes to execute and should be queued, scheduled or repeated.
MicroTasks: Functions that take less than a second to execute, but require lots of resources. Running such functions as MicroTasks will reduce concurrent execution and shall improve performance.
Ideally, _any_ execution by a module is done through these methods. This will not only ensure that all panics are caught, but will also give better insights into how your service performs.
*/
// Package modules provides a full module and task management ecosystem to
// cleanly put all big and small moving parts of a service together.
//
// Modules are started in a multi-stage process and may depend on other
// modules:
// - Go's init(): register flags
// - prep: check flags, register config variables
// - start: start actual work, access config
// - stop: gracefully shut down
//
// **Workers**
// A simple function that is run by the module while catching
// panics and reporting them. Ideal for long running (possibly) idle goroutines.
// Can be automatically restarted if execution ends with an error.
//
// **Tasks**
// Functions that take somewhere between a couple seconds and a couple
// minutes to execute and should be queued, scheduled or repeated.
//
// **MicroTasks**
// Functions that take less than a second to execute, but require
// lots of resources. Running such functions as MicroTasks will reduce concurrent
// execution and shall improve performance.
//
// Ideally, _any_ execution by a module is done through these methods. This will
// not only ensure that all panics are caught, but will also give better insights
// into how your service performs.
package modules