diff --git a/bird/parser.go b/bird/parser.go index 4a80b27..0b58e8d 100644 --- a/bird/parser.go +++ b/bird/parser.go @@ -9,7 +9,8 @@ import ( "sync" ) -const workerPoolSize = 8 +// WorkerPoolSize is the number of go routines used to parse routing tables concurrently +var WorkerPoolSize = 8 var ( ParserConf ParserConfig @@ -225,9 +226,9 @@ func startRouteWorkers(jobs chan blockJob) chan blockParsed { out := make(chan blockParsed) wg := &sync.WaitGroup{} - wg.Add(workerPoolSize) + wg.Add(WorkerPoolSize) go func() { - for i := 0; i < workerPoolSize; i++ { + for i := 0; i < WorkerPoolSize; i++ { go workerForRouteBlockParsing(jobs, out, wg) } wg.Wait() diff --git a/birdwatcher.go b/birdwatcher.go index 71eb24b..d210d14 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -107,9 +107,12 @@ func PrintServiceInfo(conf *Config, birdConf bird.BirdConfig) { func main() { bird6 := flag.Bool("6", false, "Use bird6 instead of bird") + workerPoolSize := flag.Int("worker-pool-size", 8, "Number of go routines used to parse routing tables concurrently") configfile := flag.String("config", "./etc/ecix/birdwatcher.conf", "Configuration file location") flag.Parse() + bird.WorkerPoolSize = *workerPoolSize + endpoints.VERSION = VERSION bird.InstallRateLimitReset() // Load configurations