Skip to content

Conversation

EgeBalci
Copy link
Contributor

@EgeBalci EgeBalci commented Jun 7, 2021

Hey 👋 Here are my changes.

  • There are multiple race condition bugs in sendRequest function. I have implemented two functions for safely incrementing the counters and time with using a mutex lock. (This is still not the proper way to colect values from multiple go routines, best way would be using signal channels for collecting values. But since this is a small project it would be overkill 😃 )
  • Here you give a *fasthttp.Response (pointer) to each sendRequest function, thus they all write the response into the same struct :) So, moved the fasthttp.AcquireResponse() call into sendRequest function.
  • Refactored the code by fixing coding convention naming, removing unnecessary allocations and type casting.
  • Added a timeout parameter. This is a necessary feature because net/http and fasthttp by-default has no timeout on requests, thus it hangs forever.

@utkusen utkusen merged commit af69f19 into utkusen:main Jun 7, 2021
@utkusen
Copy link
Owner

utkusen commented Jun 7, 2021

thank you for your great contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants