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

提交任务不阻塞 #24

Closed
tenfyzhong opened this issue Jan 24, 2019 · 3 comments
Closed

提交任务不阻塞 #24

tenfyzhong opened this issue Jan 24, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@tenfyzhong
Copy link

Pool.SubmitPoolWithFunc.Server提交任务,如果没有空的worker,会一直阻塞。建议增加不阻塞的接口,当前失败时直接返回错误。

@panjf2000 panjf2000 added the enhancement New feature or request label Jan 29, 2019
@choleraehyq
Copy link
Contributor

这个需求很痛,现在如果想做熔断、限流一类的逻辑要在 pool 外面再包一层,其实完全可以在 pool 里做。

@panjf2000 我理解加个配置项,直接在 retrieveWorker 里面 reentry 那个分支判断一下然后返回 nil,Submit 里加一下对 retrieveWorker 返回值的判断就可以了?如果没什么问题我来搞一下

@panjf2000
Copy link
Owner

panjf2000 commented Aug 19, 2019

大体思路应该是这样没错,我以前觉得熔断or限流这个逻辑应该在业务层实现,保持library的generality,不过好像有不少人都提出希望把这个feature加入到lib里,现在想想,熔断这个feature放到business或者放到library,貌似两个都能说得通。

So,你有时间的话提个PR吧,然后我再review一下,thanks~🤝

@choleraehyq
Copy link
Contributor

这里我觉得应该在 pool 里实现,主要是因为目前 pool 没有任何接口能让我了解现在的拥塞状况,调用了 Submit 之后就直接卡在里面了;Running 和 Cap 之类的也不大准确,对于瞬间的突发流量没法用 Running 来衡量压力。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants