mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-25 12:00:29 +00:00
Initial commit
This commit is contained in:
commit
29f583e936
135 changed files with 18463 additions and 0 deletions
20
backend/pkgs/server/worker.go
Normal file
20
backend/pkgs/server/worker.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package server
|
||||
|
||||
type Worker interface {
|
||||
Add(func())
|
||||
}
|
||||
|
||||
// SimpleWorker is a simple background worker that implements
|
||||
// the Worker interface and runs all tasks in a go routine without
|
||||
// a pool or que or limits. It's useful for simple or small applications
|
||||
// with minimal/short background tasks
|
||||
type SimpleWorker struct {
|
||||
}
|
||||
|
||||
func NewSimpleWorker() *SimpleWorker {
|
||||
return &SimpleWorker{}
|
||||
}
|
||||
|
||||
func (sw *SimpleWorker) Add(task func()) {
|
||||
go task()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue