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

feat: support custom listener #1683

Merged
merged 8 commits into from
Apr 7, 2022
Merged

feat: support custom listener #1683

merged 8 commits into from
Apr 7, 2022

Conversation

Macrow
Copy link
Contributor

@Macrow Macrow commented Mar 18, 2022

Add SetListener method for supporting custom listeners.

// 设置单个listener
ln, err := net.Listen("tcp", ":8199")
if err != nil {
  log.Fatal(err)
}
....
s := g.Server()
s.SetListener(ln)
...
s.Run()
// 设置多个listener
ln1, err := net.Listen("tcp", ":8199")
if err != nil {
  log.Fatal(err)
}
ln2, err := net.Listen("tcp", ":8299")
if err != nil {
  log.Fatal(err)
}
....
s := g.Server()
s.SetListener(ln1, ln2)
...
s.Run()

另外有相关的issue
#1043

@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2022

Codecov Report

Merging #1683 (0e0d2e1) into master (d7764e2) will decrease coverage by 0.16%.
The diff coverage is 88.46%.

@@            Coverage Diff             @@
##           master    #1683      +/-   ##
==========================================
- Coverage   71.44%   71.27%   -0.17%     
==========================================
  Files         445      452       +7     
  Lines       42754    43336     +582     
==========================================
+ Hits        30544    30888     +344     
- Misses      10295    10471     +176     
- Partials     1915     1977      +62     
Flag Coverage Δ
go-1.15 71.25% <88.46%> (-0.18%) ⬇️
go-1.16 71.24% <88.46%> (-0.16%) ⬇️
go-1.17 71.25% <88.46%> (-0.17%) ⬇️

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

Impacted Files Coverage Δ
net/ghttp/ghttp_server_config.go 61.65% <80.00%> (+1.54%) ⬆️
net/ghttp/ghttp_server_graceful.go 60.73% <100.00%> (+2.84%) ⬆️
protocol/goai/goai_response.go 46.15% <0.00%> (-34.18%) ⬇️
protocol/goai/goai_parameter.go 46.15% <0.00%> (-33.10%) ⬇️
database/gdb/gdb_core_link.go 75.00% <0.00%> (-25.00%) ⬇️
util/gvalid/gvalid.go 78.57% <0.00%> (-21.43%) ⬇️
database/gdb/gdb_model_cache.go 66.66% <0.00%> (-8.34%) ⬇️
net/gtcp/gtcp_pool.go 34.09% <0.00%> (-4.55%) ⬇️
database/gdb/gdb_model_hook.go 88.09% <0.00%> (-4.41%) ⬇️
database/gdb/gdb_core_utility.go 60.16% <0.00%> (-2.84%) ⬇️
... and 57 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7764e2...0e0d2e1. Read the comment docs.

net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
@gqcn
Copy link
Member

gqcn commented Mar 19, 2022

@Macrow 感谢参与贡献!实现的想法不错,除了代码中CR注释,这里再提点要求:任何功能的新增都应当有单元测试,以保障逻辑正确及代码质量。这一点非常重要。

@Macrow
Copy link
Contributor Author

Macrow commented Mar 19, 2022

@gqcn 已经按照你的修改意见进行了调整,添加了单元测试。

另外对初始化listeners时做了一点点调整。使用端口作为listeners的key,以用来匹配替换rawListener。

net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
@gqcn
Copy link
Member

gqcn commented Mar 21, 2022

@Macrow 同时,CI失败了,往往仅当CI成功后才会进入CR流程。

@Macrow
Copy link
Contributor Author

Macrow commented Mar 22, 2022

新增了SetListener方法,该方法会覆盖之前设置的地址端口。

另外,我在本地通过了所有测试,但github上的ci测试没有通过,点击进入错误详情看不到具体哪里出错,能否看看具体哪里测试没过?

F8E059F6-9726-40F9-BC06-A4B4E7705C2C

@Macrow
Copy link
Contributor Author

Macrow commented Mar 29, 2022

@gqcn 强哥有空帮忙看看ci错误在哪儿?

net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
net/ghttp/ghttp_server_config.go Outdated Show resolved Hide resolved
net/ghttp/ghttp_z_unit_feature_custom_listeners_test.go Outdated Show resolved Hide resolved
@gqcn
Copy link
Member

gqcn commented Mar 29, 2022

@Macrow
image

@Macrow Macrow requested a review from gqcn March 31, 2022 03:57
@Macrow Macrow requested a review from gqcn April 1, 2022 01:37
@gqcn gqcn merged commit 09c3425 into gogf:master Apr 7, 2022
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.

3 participants