ccproxy.plugins.credential_balancer.manager¶
ccproxy.plugins.credential_balancer.manager
¶
Credential rotation manager for the credential balancer plugin.
CredentialEntry
dataclass
¶
CredentialEntry(
config,
manager,
max_failures,
cooldown_seconds,
logger,
_failure_count=0,
_disabled_until=None,
)
Wrapper for an AuthManager with failure tracking and cooldown logic.
get_access_token
async
¶
Get access token from the composed manager.
Returns:
| Type | Description |
|---|---|
str
|
Access token string |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If no valid token available |
Source code in ccproxy/plugins/credential_balancer/manager.py
get_access_token_with_refresh
async
¶
Get access token with automatic refresh if supported.
Returns:
| Type | Description |
|---|---|
str
|
Access token string |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If no valid token available |
Source code in ccproxy/plugins/credential_balancer/manager.py
is_authenticated
async
¶
Check if manager has valid authentication.
Returns:
| Type | Description |
|---|---|
bool
|
True if authenticated, False otherwise |
Source code in ccproxy/plugins/credential_balancer/manager.py
mark_failure
¶
Record a failure and potentially disable this credential.
Source code in ccproxy/plugins/credential_balancer/manager.py
reset_failures
¶
Reset failure count and re-enable this credential.
Source code in ccproxy/plugins/credential_balancer/manager.py
is_disabled
¶
Check if this credential is currently disabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
now
|
float
|
Current monotonic time |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if disabled, False if available |
Source code in ccproxy/plugins/credential_balancer/manager.py
CredentialBalancerTokenManager
¶
Bases: AuthManager
Auth manager that rotates across multiple credential sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
CredentialPoolConfig
|
Pool configuration |
required |
entries
|
list[CredentialEntry]
|
List of credential entries with composed managers |
required |
logger
|
TraceBoundLogger | None
|
Optional logger for this manager |
None
|
Source code in ccproxy/plugins/credential_balancer/manager.py
create
async
classmethod
¶
Async factory to create balancer with composed managers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
CredentialPoolConfig
|
Pool configuration |
required |
factory
|
AuthManagerFactory | None
|
Auth manager factory for creating managers from sources |
None
|
logger
|
TraceBoundLogger | None
|
Optional logger for this manager |
None
|
Returns:
| Type | Description |
|---|---|
CredentialBalancerTokenManager
|
Initialized CredentialBalancerTokenManager instance |
Source code in ccproxy/plugins/credential_balancer/manager.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
get_access_token
async
¶
Get access token from selected credential entry.
Returns:
| Type | Description |
|---|---|
str
|
Access token string |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If no valid token available |
Source code in ccproxy/plugins/credential_balancer/manager.py
get_access_token_with_refresh
async
¶
Get access token with automatic refresh if supported.
Returns:
| Type | Description |
|---|---|
str
|
Access token string |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If no valid token available |
Source code in ccproxy/plugins/credential_balancer/manager.py
is_authenticated
async
¶
Check if any credential is authenticated.
Returns:
| Type | Description |
|---|---|
bool
|
True if at least one credential is authenticated, False otherwise |
Source code in ccproxy/plugins/credential_balancer/manager.py
get_user_profile
async
¶
Get user profile (not available for balancer).
Returns:
| Type | Description |
|---|---|
StandardProfileFields | None
|
None, as balancer aggregates multiple credentials |
get_profile_quick
async
¶
Get profile information without I/O (for compatibility).
Returns:
| Type | Description |
|---|---|
Any
|
None, as balancer doesn't maintain profile cache |
validate_credentials
async
¶
Validate that credentials are available and valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if valid credentials available, False otherwise |
get_provider_name
¶
load_credentials
async
¶
Load token snapshots from all credential entries.
Returns:
| Type | Description |
|---|---|
dict[str, TokenSnapshot | None]
|
Dictionary mapping credential labels to their token snapshots |
Source code in ccproxy/plugins/credential_balancer/manager.py
get_token_snapshot
async
¶
Get token snapshot from selected credential entry.
Returns:
| Type | Description |
|---|---|
TokenSnapshot | None
|
TokenSnapshot if available, None otherwise |