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

[Feature]: cred 缓存与失败重签 #47

Open
3 tasks
AzideCupric opened this issue Jan 12, 2024 · 4 comments
Open
3 tasks

[Feature]: cred 缓存与失败重签 #47

AzideCupric opened this issue Jan 12, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@AzideCupric
Copy link
Collaborator

AzideCupric commented Jan 12, 2024

起因:

在目前的签到流程中,每次签到都会进行令牌请求,这会在短时间内造成大量的API使用 (yj: 警觉),可能会导致服务器拒绝签到(只能说已经碰到了)。

签到失败:Client error '400 Bad Request' for url 'https://as.hypergryph.com/user/oauth2/v2/grant'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

此外,目前没有机制来识别并重试由于这些特定错误导致的签到失败。
感觉是时候添加缓存机制来存储cred,以及对失败签到在一定时间后重试的功能了。

方案:

  1. 签到时缓存cred: 修改签到流程,将成功签到时获取的cred缓存到数据库。签到时优先使用缓存的cred,如果cred签到失败,则重新使用token请求新的cred并缓存。

  2. 识别失败的签到: 判定特定错误导致的签到失败,例如上文的400 Bad Request。通过分析签到过程中收到的响应,识别错误代码或错误信息等手段实现。

  3. 重试失败的签到: 识别到失败的签到尝试后,将本次失败的签到用户进行记录,创建一个<签到重试间隔>后执行的定时器,对这些用户进行重新签到。对此应该有签到重试间隔最大签到重试次数配置

预期:

  1. 提升性能:缓存cred将减少令牌请求次数,从而提升性能并减少API使用量。
  2. 加快签到流程:使用缓存的cred,签到流程将更快,因为不需要为每次尝试进行令牌请求 降低被yj击毙的可能
  3. 提升用户体验:通过识别并自动重试失败的签到,可以减少发现签到失败之后的手动触发签到操作。

步骤:

  1. 确定缓存cred的位置。
  2. 实现缓存机制,在签到流程中存储、获取、刷新cred。
  3. 识别并记录签到失败的尝试。
  4. 实现重试机制,在固定间隔后对可重签失败重新触发签到。
  5. 实施适当的日志记录和监控,跟踪缓存和重试机制的成功情况。

其他考虑事项:

  • 是否需要记录签到用户的当前签到状态和重签次数,并提供相应的查询命令?

ToDo List:

  • 签到流程中缓存、使用、刷新 cred
  • 强制手动刷新 cred 的命令
  • 自动重签机制
@AzideCupric AzideCupric added the enhancement New feature or request label Jan 12, 2024
@AzideCupric AzideCupric changed the title [Feature] cred 缓存与失败重签 [Feature]: cred 缓存与失败重签 Jan 12, 2024
@AzideCupric
Copy link
Collaborator Author

可能会导致服务器拒绝签到

确认并不是这个的问题,已经在 #48 修复

@GuGuMur
Copy link
Owner

GuGuMur commented Jan 13, 2024

上周六有群友也说了 当时的方案是个人signin 然后监狱里路上有想过一点处理方案

下周考完试过来看看(

@AzideCupric
Copy link
Collaborator Author

AzideCupric commented Jan 13, 2024

反过来想可以默认失败重签,但是可以手动显式暂停某个账号的失败重签功能(

@GuGuMur
Copy link
Owner

GuGuMur commented Jan 13, 2024

猫头 震惊.jpg

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

2 participants