mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-25 00:06:31 +00:00
bd321af29f
* new PR tasks * add homebox to know words * formatting * bump deps * generate db models * ts errors * drop id * fix accessor * drop unused time field * change CI * add expected error * add type check * resolve serveral type errors * hoise in CI
21 lines
496 B
Go
21 lines
496 B
Go
package server
|
|
|
|
// TODO: #2 Implement Go routine pool/job queue
|
|
|
|
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()
|
|
}
|