1
0
Fork 1
mirror of https://github.com/hay-kot/homebox.git synced 2025-02-19 10:50:07 +00:00
homebox/backend/pkgs/server/worker.go
2022-08-29 18:30:36 -08:00

20 lines
449 B
Go

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()
}