Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow creation of multiple engines on the same protocol and port #419

Merged
merged 4 commits into from
Nov 4, 2022

Conversation

jdamick
Copy link
Contributor

@jdamick jdamick commented Nov 1, 2022


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

  • [x ] I have squashed all insignificant commits.
  • [x ] I have commented my code for explaining package types, values, functions, and non-obvious lines.
  • [x ] I have written unit tests and verified that all tests passes (if needed).
  • [? ] I have documented feature info on the README (only when this PR is adding a new feature).
  • [x ] (optional) I am willing to help maintain this change if there are issues with it later.

I'm happy to add documentation to the README, just let me know if and where it makes sense?

@panjf2000
Copy link
Owner

Sorry for the delay.

I think we should mark gnet.Stop() as Deprecated if we're trying to merge this PR.

Copy link
Owner

@panjf2000 panjf2000 left a comment

Choose a reason for hiding this comment

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

Please add // Deprecated: on gnet.Stop()

@jdamick
Copy link
Contributor Author

jdamick commented Nov 3, 2022

Sure, and will fix the the test issue.

@codecov
Copy link

codecov bot commented Nov 4, 2022

Codecov Report

Base: 71.26% // Head: 71.23% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (674c206) compared to base (20ff40b).
Patch coverage: 68.75% of modified lines in pull request are covered.

❗ Current head 674c206 differs from pull request most recent head ecb2994. Consider uploading reports for the commit ecb2994 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #419      +/-   ##
==========================================
- Coverage   71.26%   71.23%   -0.03%     
==========================================
  Files          13       13              
  Lines        1392     1408      +16     
==========================================
+ Hits          992     1003      +11     
- Misses        328      332       +4     
- Partials       72       73       +1     
Flag Coverage Δ
unittests 71.23% <68.75%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gnet.go 73.84% <68.75%> (-0.72%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

gnet.go Outdated Show resolved Hide resolved
@panjf2000 panjf2000 merged commit 9d7fdd2 into panjf2000:dev Nov 4, 2022
@panjf2000
Copy link
Owner

Thanks~

0-haha pushed a commit to 0-haha/gnet that referenced this pull request Jan 25, 2023
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.

None yet

2 participants