App
fastgrpc.app.App
dataclass
Source code in src/fastgrpc/app.py
proto_dir
class-attribute
instance-attribute
Directory where the human-readable .proto file is written. Visible, committable, refreshed on every reload. If None (default), it's emitted next to the entry-point .py file — your service owns its own contract.
proto_out
class-attribute
instance-attribute
Directory for compiled stubs (_pb2.py / _pb2_grpc.py). Gitignored.
fastgrpc.app.Interceptor
Example
from fastgrpc import App, rpc, service
cfg = App(host="0.0.0.0", port=50051, max_workers=20)
@cfg.interceptor
async def logging_interceptor(method, request, context, call_next):
print(f"→ {method}")
response = await call_next(method, request, context)
print(f"← {method}")
return response
@service
class UserService:
@rpc
async def get_user(self, user_id: int) -> User: ...
Configuration fields
| Field | Default | Purpose |
|---|---|---|
host |
127.0.0.1 |
Bind address |
port |
50051 |
Bind port |
max_workers |
10 |
Thread pool size (sync server only) |
reflection |
True |
Enable gRPC server reflection |
proto_dir |
None |
Where to write the human-readable .proto. CLI sets this to .fastgrpc/ automatically. |
proto_out |
.fastgrpc |
Where compiled _pb2.py stubs go |
lock_path |
.fastgrpc.lock |
Field-number lock file location |
interceptors |
[] |
List of registered interceptors |