diff --git a/cmd/server/run.go b/cmd/server/run.go index 0815f38..4a9f862 100644 --- a/cmd/server/run.go +++ b/cmd/server/run.go @@ -67,7 +67,9 @@ func Run(cmd *cobra.Command, args []string) { // Process queue queue := make(chan func() error, 0) - go ProcessQueue(queue) + for i := 0; i < workers; i++ { + go ProcessQueue(queue) + } // Listen http.HandleFunc("/webhook", WebhookHandler(webhookSecret, sonar, gh, queue)) @@ -143,7 +145,7 @@ func WebhookHandler(webhookSecret string, sonar *sonarqube2.Sonarqube, gh scm2.S // if the request takes more than 10s Sonarqube shows the message 'Server Unreachable' func ProcessQueue(queue <-chan func() error) { for fn := range queue { - err := retry.Do(fn, retry.Delay(time.Minute), retry.Attempts(5)) + err := retry.Do(fn, retry.Delay(time.Minute), retry.DelayType(retry.FixedDelay), retry.Attempts(5)) if err != nil { logrus.WithError(err).Errorln("Failed to process webhook") diff --git a/cmd/server/server.go b/cmd/server/server.go index b33ff8b..3aab48d 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -5,6 +5,7 @@ import ( ) var serverPort int +var workers int var ServerCmd = &cobra.Command{ Use: "server", @@ -13,5 +14,6 @@ var ServerCmd = &cobra.Command{ func init() { ServerCmd.PersistentFlags().IntVarP(&serverPort, "port", "p", 8080, "Server port") + ServerCmd.PersistentFlags().IntVarP(&workers, "workers", "w", 30, "Workers count") ServerCmd.AddCommand(RunCmd) }