Skip to content

Commit

Permalink
Simplify stopLoadTestIfNoWorkerRemaining
Browse files Browse the repository at this point in the history
  • Loading branch information
andylibrian committed Apr 1, 2021
1 parent 81b217d commit 81bfa4a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ func (s *Server) acceptWorkerConn(responseWriter http.ResponseWriter, req *http.

logger.Infow("Worker connected", "name", name)

defer s.stopLoadTestIfNoWorkerRemaining()
defer logger.Infow("Worker removed", "name", name)
defer s.workerService.RemoveWorker(conn)
defer conn.Close()
defer s.stopLoadTestIfNoWorkerRemaining()

for {
_, message, err := conn.ReadMessage()
Expand All @@ -188,10 +188,8 @@ func (s *Server) acceptWorkerConn(responseWriter http.ResponseWriter, req *http.
}
}

func (s *Server) stopLoadTestIfNoWorkerRemaining(){
val := len(s.workerService.workers) - 1
logger.Infow("Number of remaining workers: ", "", val)
if val == 0 {
func (s *Server) stopLoadTestIfNoWorkerRemaining() {
if len(s.workerService.workers) == 0 {
s.loadTestState = messages.ServerStateStopped
}
}
Expand Down

0 comments on commit 81bfa4a

Please # to comment.