Skip to content

create ports locally to fastcache server#5

Open
swelborn wants to merge 4 commits into
mainfrom
create-ports-locally
Open

create ports locally to fastcache server#5
swelborn wants to merge 4 commits into
mainfrom
create-ports-locally

Conversation

@swelborn

@swelborn swelborn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_by for 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants