mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
feat: implement data retention mechanism
This commit is contained in:
@@ -12,10 +12,11 @@ var jobQueues map[string]*artifex.Dispatcher
|
||||
var jobCounts map[string]int
|
||||
|
||||
const (
|
||||
QueueDefault = "wakapi.default"
|
||||
QueueProcessing = "wakapi.processing"
|
||||
QueueReports = "wakapi.reports"
|
||||
QueueImports = "wakapi.imports"
|
||||
QueueDefault = "wakapi.default"
|
||||
QueueProcessing = "wakapi.processing"
|
||||
QueueReports = "wakapi.reports"
|
||||
QueueImports = "wakapi.imports"
|
||||
QueueHousekeeping = "wakapi.housekeeping"
|
||||
)
|
||||
|
||||
type JobQueueMetrics struct {
|
||||
@@ -28,9 +29,10 @@ func init() {
|
||||
jobQueues = make(map[string]*artifex.Dispatcher)
|
||||
|
||||
InitQueue(QueueDefault, 1)
|
||||
InitQueue(QueueProcessing, int(math.Ceil(float64(runtime.NumCPU())/2.0)))
|
||||
InitQueue(QueueProcessing, halfCPUs())
|
||||
InitQueue(QueueReports, 1)
|
||||
InitQueue(QueueImports, 1)
|
||||
InitQueue(QueueHousekeeping, halfCPUs())
|
||||
}
|
||||
|
||||
func InitQueue(name string, workers int) error {
|
||||
@@ -71,3 +73,11 @@ func CloseQueues() {
|
||||
q.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func allCPUs() int {
|
||||
return runtime.NumCPU()
|
||||
}
|
||||
|
||||
func halfCPUs() int {
|
||||
return int(math.Ceil(float64(runtime.NumCPU()) / 2.0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user