ksysoev / wasabi

Toolkit for Creating WebSocket API Gateways
MIT License
4 stars 2 forks source link

"Implement connection limit for WebSocket connections" #64

Closed ksysoev closed 1 month ago

ksysoev commented 1 month ago

This pull request adds the ability to limit the number of active WebSocket connections in the ConnectionRegistry. It introduces a new method, CanAccept(), which checks if the registry can accept new connections based on the specified connection limit. If the connection limit is reached, a "Connection limit reached" error message is returned. The AddConnection() method has been updated to check the connection limit before adding a new connection. Additionally, a new option, WithConnectionLimit(), has been added to set the maximum number of connections that can be accepted by the ConnectionRegistry.

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 89.28571% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 90.63%. Comparing base (51aea57) to head (25bdd6b).

Files Patch % Lines
channel/channel.go 57.14% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #64 +/- ## ========================================== + Coverage 89.24% 90.63% +1.39% ========================================== Files 20 20 Lines 818 844 +26 ========================================== + Hits 730 765 +35 + Misses 66 58 -8 + Partials 22 21 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.