keepAlive功能,增加选项控制重试次数和重试间隔 #45
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
此前的讨论见#40。
根据 #40 (comment) 的建议,本PR实现了keepAliveLoop并不会在请求失败就立即退出,而是重复尝试可定义的次数,只有连续失败若干次后才会退出。同时,两次重试之间的时间间隔现在也可定义了(之前是写死的3s)。
具体实现:
auth-thu auth --keep-online的keepAlive,应该根据--campus-only的有无决定keepAlive的校内校外,而不应固定写死keepAlive校内。onlineRetry,决定keepAliveLoop在退出之前应当尝试的次数,默认值为2,即只有连续两次keepAlive请求报错,keepAliveLoop才会退出。onlineInterval,决定两次keepAlive请求之间的间隔,默认值为3s(和原来写死在代码里的值一致)auth-thu online --auth的--auth增加一个alias名为--campus-only。这是因为--auth原本在旧版的系统下表示只auth不login,但目前login功能已被完全移除,故该名称也失去了其含义;改为--campus-only,是和auth-thu auth中的同义选项保持一致的选择。Close #40.