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

EventStream断开期间事件的推送 #48

Open
hcfw007 opened this issue May 23, 2023 · 3 comments
Open

EventStream断开期间事件的推送 #48

hcfw007 opened this issue May 23, 2023 · 3 comments

Comments

@hcfw007
Copy link
Member

hcfw007 commented May 23, 2023

我们如何感知断开?
通过事件不能保证,只能通过调用grpc event方法时传一个参数来告诉server端最后一条事件是什么。

如果只处理Message:
那我们可以在调用event时传一个最后一条Message的id,然后底层根据id反查从该id的消息到现在的时间点的消息,把这些消息emit出去。

如果要处理所有事件:
那么我们可以新建一个表,把所有事件和payload和timestamp都塞进去。当bot调用event时,带上最后一条事件的时间,然后把该时间点到现在的所有事件都emit出去。这个表可以每天清理一次。

@hcfw007
Copy link
Member Author

hcfw007 commented May 23, 2023

暂时不考虑中间漏事件的情况。即底层事件a->b->c,ac收到了b漏了。

@hcfw007
Copy link
Member Author

hcfw007 commented May 23, 2023

计划采取以下措施:
server端在grpc的Event payload中添加seq,并入库。当client端收到事件后,更新seq(只增加)。在连接EventStream的时候,如果存了seq,则传过去,server端根据seq将之后的事件再抛出。

可能client端也需要记录timestamp,并将seq落盘,以应对bot重启的情况和bot离线时间较长的情况。

@hcfw007
Copy link
Member Author

hcfw007 commented May 23, 2023

juzibot/wechaty-grpc#44

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

No branches or pull requests

1 participant