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