allow creation of multiple engines on the same protocol and port #419
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
name: Pull request
about: Currently with the allEngines global map multiple engines can't be created for the same protocol and port. If they are then there is no way to Stop the first engine since any subsequent engines will overwrite the entry in the allEngines map. Changing this map and the behavior of the gnet.Stop() is a bigger change so I merely added a Stop(..) function to the Engine so that it could Stopped and not leak.
title: ''
labels: ''
assignees: ''
1. Are you opening this pull request for bug-fixes, optimizations or new feature?
Yes.
2. Please describe how these code changes achieve your intention.
Currently with the allEngines global map multiple engines can't be created for the same protocol and port. If they are then there is no way to Stop the first engine since any subsequent engines will overwrite the entry in the allEngines map. Changing this map and the behavior of the gnet.Stop() is a bigger change so I merely added a Stop(..) function to the Engine so that it could Stopped and not leak.
Why enable multiple engines for the same protocol & port?
When using ReuseAddr and ReusePort then it's possible to swap in a new engine to the same address & port and disable the old one without incurring a restart of the server. This is the use case I currently have and would like to enable.
3. Please link to the relevant issues (if any).
4. Which documentation changes (if any) need to be made/updated because of this PR?
Documentation for Engine.Stop(..)
4. Checklist
I'm happy to add documentation to the README, just let me know if and where it makes sense?