make number of workers tuneable by an env var
Jeromy committed
Apr 17, 2015 at 15:57 UTC
3629d7d5482be131c872ba57e95450a2a204bd7b
1 file changed
+14
-1
exchange/bitswap/workers.go
+14
-1
@@ -1,6 +1,8 @@
1
package bitswap
2
3
import (
4
+ "os"
5
+ "strconv"
6
"time"
7
8
inflect "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/chuckpreslar/inflect"
@@ -9,7 +11,18 @@ import (
11
u "github.com/ipfs/go-ipfs/util"
12
)
13
12
-var TaskWorkerCount = 4
14
+var TaskWorkerCount = 16
15
+
16
+func init() {
17
+ twc := os.Getenv("IPFS_TASK_WORKERS")
18
+ if twc != "" {
19
+ n, err := strconv.Atoi(twc)
20
+ if err != nil {
21
+ return
22
+ }
23
+ TaskWorkerCount = n
24
+ }
25
+}
26
27
func (bs *Bitswap) startWorkers(px process.Process, ctx context.Context) {
28
// Start up a worker to handle block requests this node is making