Download app/dataplane/account/lease.py from LifeVta/Grok3API: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/LifeVta/Grok3API/resolve/main/app/dataplane/account/lease.py
- Command line
-
hf download hf://spaces/LifeVta/Grok3API/app/dataplane/account/lease.py
-
curl -L -o lease.py https://huggingface.co/spaces/LifeVta/Grok3API/resolve/main/app/dataplane/account/lease.py
1.12 kB
| """AccountLease — minimal hot-path rental object.""" | |
| from dataclasses import dataclass | |
| from app.platform.runtime.ids import next_id | |
| class AccountLease: | |
| """Represents a reserved account slot for a single upstream request. | |
| Holds only the minimum fields needed on the hot path — no AccountRecord. | |
| The slot *idx* allows O(1) array access for feedback updates. | |
| """ | |
| lease_id: int # monotonic counter — cheaper than uuid | |
| idx: int # slot in AccountRuntimeTable | |
| token: str # cached for header building | |
| pool_id: int # PoolId integer | |
| mode_id: int # ModeId integer | |
| selected_at: int # ms timestamp | |
| def new_lease(idx: int, token: str, pool_id: int, mode_id: int, selected_at: int) -> AccountLease: | |
| """Construct an AccountLease with an auto-incremented id.""" | |
| return AccountLease( | |
| lease_id = next_id(), | |
| idx = idx, | |
| token = token, | |
| pool_id = pool_id, | |
| mode_id = mode_id, | |
| selected_at = selected_at, | |
| ) | |
| __all__ = ["AccountLease", "new_lease"] | |