Cranker v3 connector for ASGI applications
Project description
asgi-cc
asgi-cc is a Python Cranker connector for ASGI applications. It connects an ASGI app to a Cranker router over WebSocket and forwards HTTP traffic through the Cranker v3 protocol without adding a loopback HTTP hop inside the service process.
Features
- ASGI-native request and response bridging
- Cranker v3 (
cranker_3.0) protocol support - FastAPI-compatible integration
- DNS-based router discovery
- Runtime app attach and detach support
Requirements
- Python
3.11+
Installation
pip install asgi-cc
Basic Usage
Create the connector with the application and let the app lifecycle manage the connector:
import os
from fastapi import FastAPI
from asgi_cc import CrankerConnector, CrankerConnectorConfig
app = FastAPI()
@app.get("/hello")
async def hello() -> dict[str, str]:
return {"message": "hello through cranker"}
connector = CrankerConnector(
app,
CrankerConnectorConfig(
router_urls=[os.environ.get("CRANKER_ROUTER_URL", "wss://localhost:12001")],
route="*",
verify_ssl=False,
component_name="my-service",
),
)
Keep using app as the ASGI server entrypoint. The connector registers itself on the app startup and shutdown hooks.
Middleware Usage
import os
from fastapi import FastAPI
from asgi_cc import CrankerConnector, CrankerConnectorConfig
app = FastAPI()
app.add_middleware(
CrankerConnector,
config=CrankerConnectorConfig(
router_urls=[os.environ.get("CRANKER_ROUTER_URL", "wss://localhost:12001")],
route="*",
verify_ssl=False,
component_name="my-service",
),
)
Runtime App Management
connector = CrankerConnector(config=config)
await connector.attach(app)
await connector.detach()
If the connector is started without an attached app, incoming requests receive 503 Service Unavailable until an app is attached.
Router Discovery
config = CrankerConnectorConfig(
router_urls=["wss://router.example.org"],
route="*",
router_lookup_by_dns=True,
router_update_interval_seconds=60,
)
When enabled, asgi-cc resolves router hostnames to IP addresses, opens registrations for the currently resolved routers, and periodically reconciles router registrations as DNS changes.
Project Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asgi_cc-0.1.2.tar.gz.
File metadata
- Download URL: asgi_cc-0.1.2.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e215dc74123b59f7f14b691542a09d3b4ae4921b11cb598565bf545aabe9e05f
|
|
| MD5 |
0054b6e4a826ae2136463d87fcc0d058
|
|
| BLAKE2b-256 |
4790d20d1ca0a3036f718115f5602c09e6d111dbc8d0bd5856eb340c2173d765
|
Provenance
The following attestation bundles were made for asgi_cc-0.1.2.tar.gz:
Publisher:
release.yml on wenLiangcan/asgi-cc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asgi_cc-0.1.2.tar.gz -
Subject digest:
e215dc74123b59f7f14b691542a09d3b4ae4921b11cb598565bf545aabe9e05f - Sigstore transparency entry: 1350755631
- Sigstore integration time:
-
Permalink:
wenLiangcan/asgi-cc@a49f2ec6ac749914657cd875be206c5ae4fce3df -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/wenLiangcan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a49f2ec6ac749914657cd875be206c5ae4fce3df -
Trigger Event:
release
-
Statement type:
File details
Details for the file asgi_cc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: asgi_cc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c6b4ef30f56eb78de121100fbb06e922d46a24347e12c014154c6ff676d403f
|
|
| MD5 |
8111736a529ce100f476ec568ea2682c
|
|
| BLAKE2b-256 |
be94c3dd0cf3e97ab48573172d826bab339ea46944a065e1498d4822887c363a
|
Provenance
The following attestation bundles were made for asgi_cc-0.1.2-py3-none-any.whl:
Publisher:
release.yml on wenLiangcan/asgi-cc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asgi_cc-0.1.2-py3-none-any.whl -
Subject digest:
8c6b4ef30f56eb78de121100fbb06e922d46a24347e12c014154c6ff676d403f - Sigstore transparency entry: 1350755679
- Sigstore integration time:
-
Permalink:
wenLiangcan/asgi-cc@a49f2ec6ac749914657cd875be206c5ae4fce3df -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/wenLiangcan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a49f2ec6ac749914657cd875be206c5ae4fce3df -
Trigger Event:
release
-
Statement type: