Skip to content

Added WithConnLimiter option for resource manager#1

Open
sstanculeanu wants to merge 2 commits intomasterfrom
conn_limiter_option
Open

Added WithConnLimiter option for resource manager#1
sstanculeanu wants to merge 2 commits intomasterfrom
conn_limiter_option

Conversation

@sstanculeanu
Copy link
Owner

Considering the case where multiple hosts are running on the same ip, it would be very hard to decide what would be the proper limit in terms of using one. Although the default options, with ConnCount set to math.MaxInt would be fix this problem, the internal array of maps would still consume a lot of memory.

WithConnLimiter option would be a great option in order to allow clients their own custom implementation of the connLimiter. In our case, simply use an empty limiter would be the best option for the moment.

Also added a tiny change request on the readme, in order to completely align with our new naming.

@sstanculeanu sstanculeanu self-assigned this Jul 15, 2024
- [Flow](https://github.com/onflow/flow-go) - A blockchain built to support games, apps, and digital assets built by [Dapper Labs](https://www.dapperlabs.com/)
- [Swarm Bee](https://github.com/ethersphere/bee) - A client for connecting to the [Swarm network](https://www.ethswarm.org/)
- [Elrond Go](https://github.com/multiversx/mx-chain-go) - The Go implementation of the the Elrond network protocol
- [MultiversX Node](https://github.com/multiversx/mx-chain-go) - The Go implementation of the MultiversX network protocol

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return func(rm *resourceManager) error {
connLimiterInstance, ok := rm.connLimiter.(*connLimiter)
if !ok {
return nil // early exit, it might be a custom implementation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe throw an error here? Just to signal that the method call did not produce the expected result. Valid also on L100

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


if ipv4 != nil {
rm.connLimiter.connLimitPerSubnetV4 = ipv4
connLimiterInstance.connLimitPerSubnetV4 = ipv4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to protect this set method with the same connLimiter.mu mutex. Maybe extract these set methods in the implementation + interface and get rid of the casts?

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