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

optimize search logic for bridgeTweetSearchServant #190

Merged
merged 1 commit into from
Nov 3, 2022
Merged

optimize search logic for bridgeTweetSearchServant #190

merged 1 commit into from
Nov 3, 2022

Conversation

alimy
Copy link
Collaborator

@alimy alimy commented Nov 3, 2022

  • optimize search logic for bridge use two level channel to dynamic process docs update

pr特性:
解决search繁忙时过度快速的生成大量goroutine。
这里使用go channel的mpmc特性,采用二级channel的机制,前一级channel由固定goroutine(“正式工”)消费channel的消息,channel如果满了,消息就会发送到二级channel,由二级channel的依存临时goroutine("临时工") 消费其中的消息,如果二级channel也满了,就新建goroutine来消费消息,并将该goroutine作为"临时工"监听二级channel中的消息,当“临时工”处理完手头的消息后,继续去抢二级channel中的消息,抢到了消息就消费(同时清零自己抢消息的计数),没抢到就等待一定时间再去抢,连续抢个固定来回后,直接返回退出(自我毁灭),如此就形成了一个有条件自生自灭的临时goroutine生成机制。

@alimy alimy merged commit f2d674c into dev Nov 3, 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
1 participant