mirror of
https://github.com/safing/portbase
synced 2025-09-14 09:09:50 +00:00
Finish modules/tasks revamp
This commit is contained in:
parent
4e99dd2153
commit
71dabc1f23
11 changed files with 542 additions and 296 deletions
18
modules/doc.go
Normal file
18
modules/doc.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue