File tree 3 files changed +38
-24
lines changed 3 files changed +38
-24
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,8 @@ package taskq
3
3
import (
4
4
"fmt"
5
5
"math/rand"
6
- "runtime"
7
6
"time"
8
7
9
- "github.com/capnm/sysinfo"
10
8
"github.com/vmihailenco/taskq/v3/internal"
11
9
)
12
10
@@ -317,25 +315,3 @@ func (r *configRoulette) withMoreFetchers(cfg *consumerConfig) *consumerConfig {
317
315
func significant (n float64 ) bool {
318
316
return n > 0.05
319
317
}
320
-
321
- func hasFreeSystemResources () bool {
322
- si := sysinfo .Get ()
323
- free := si .FreeRam + si .BufferRam
324
-
325
- // at least 200MB of RAM is free
326
- if free < 2e5 {
327
- return false
328
- }
329
-
330
- // at least 5% of RAM is free
331
- if float64 (free )/ float64 (si .TotalRam ) < 0.05 {
332
- return false
333
- }
334
-
335
- // avg load is not too high
336
- if si .Loads [0 ] > 1.5 * float64 (runtime .NumCPU ()) {
337
- return false
338
- }
339
-
340
- return true
341
- }
Original file line number Diff line number Diff line change
1
+ // +build linux
2
+
3
+ package taskq
4
+
5
+ import (
6
+ "runtime"
7
+
8
+ "github.com/capnm/sysinfo"
9
+ )
10
+
11
+ func hasFreeSystemResources () bool {
12
+ si := sysinfo .Get ()
13
+ free := si .FreeRam + si .BufferRam
14
+
15
+ // at least 200MB of RAM is free
16
+ if free < 2e5 {
17
+ return false
18
+ }
19
+
20
+ // at least 5% of RAM is free
21
+ if float64 (free )/ float64 (si .TotalRam ) < 0.05 {
22
+ return false
23
+ }
24
+
25
+ // avg load is not too high
26
+ if si .Loads [0 ] > 1.5 * float64 (runtime .NumCPU ()) {
27
+ return false
28
+ }
29
+
30
+ return true
31
+ }
Original file line number Diff line number Diff line change
1
+ // +build !linux
2
+
3
+ package taskq
4
+
5
+ func hasFreeSystemResources () bool {
6
+ return true
7
+ }
You can’t perform that action at this time.
0 commit comments