taolib.github_app.events#
令牌生命周期事件协议与默认实现。
本模块定义了令牌管理器在令牌刷新成功或失败时的回调协议,
调用方可实现 TokenEventHook 以接入审计日志、监控等场景。
Classes#
空操作实现,默认注入,不产生任何副作用。 |
|
令牌事件回调协议。 |
Module Contents#
- class taolib.github_app.events.NullTokenEventHook#
空操作实现,默认注入,不产生任何副作用。
- async on_token_refreshed(cache_key: str, result: taolib.github_app.models.InstallationTokenResult) None#
空操作:令牌刷新成功时不执行任何动作。
- class taolib.github_app.events.TokenEventHook#
Bases:
Protocol令牌事件回调协议。
调用方实现此协议并注入到
GitHubInstallationTokenManager, 即可在令牌刷新成功或失败时收到通知。- async on_token_refresh_failed(cache_key: str, error: Exception) None#
令牌刷新失败时触发。
- 参数:
cache_key -- 本次刷新对应的缓存键。
error -- 导致刷新失败的异常。
- async on_token_refreshed(cache_key: str, result: taolib.github_app.models.InstallationTokenResult) None#
令牌刷新成功时触发。
- 参数:
cache_key -- 本次刷新对应的缓存键。
result -- 刷新后的令牌结果。