create ports locally to fastcache server#5
Open
swelborn wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates cache creation so the API server always publishes ZMQ URIs using the server’s canonical hostname (FQDN) and assigns pull/push ports locally from a configured range, rather than relying on the request body to supply host/port details.
Changes:
- Allocate cache pull/push port pairs server-side based on active caches, and publish URIs using a canonical hostname.
- Update process utilities to compute canonical hostname and allocate port pairs.
- Simplify the cache creation request schema by removing hostname/port inputs and adding
requested_byfor attribution.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/fastcache_api/routes/cache.py | Allocates hostname/ports locally during cache creation and records requested_by on the cache row. |
| src/fastcache_api/process.py | Adds canonical hostname + port-allocation helpers for cache startup. |
| src/fastcache_api/models.py | Updates CacheRequest schema to remove hostname/port fields and add requested_by. |
| src/fastcache_api/config.py | Introduces configurable cache port range settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+68
to
+72
| active = await session.execute( | ||
| select(Cache).where( | ||
| Cache.state.in_([s.value for s in CacheState if not s.is_final()]) | ||
| ) | ||
| ) |
Comment on lines
+21
to
+27
| def ports_in_use(configs: Iterable[CacheConfig]) -> set[int]: | ||
| used: set[int] = set() | ||
| for config in configs: | ||
| for uri in (config.pull_uri, config.push_uri): | ||
| if uri.port is not None: | ||
| used.add(uri.port) | ||
| return used |
Comment on lines
+16
to
+18
| def canonical_hostname() -> str: | ||
| """This host's preferred public name for cache ZMQ URIs.""" | ||
| return (socket.getfqdn() or socket.gethostname()).lower() |
Comment on lines
+48
to
+49
| CACHE_PORT_START: int = 30000 | ||
| CACHE_PORT_END: int = 30100 |
This was referenced Jun 30, 2026
This was referenced Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
the cache request loses its pull/push ports and hostname here, and we use fqdn for the hostname
This is part 1 of 10 in a stack made with GitButler: