Add a client extension API (#3034)
This commit is contained in:
parent
7322ca56f4
commit
4df609119f
1 changed files with 3410 additions and 180 deletions
|
|
@ -28,18 +28,16 @@ uv run python -m stories.custom_methods.client --http
|
|||
method string is the wire `method`; use a vendor prefix so it can never
|
||||
collide with a future spec method.
|
||||
- `client.py` `client.session.send_request(...)` — `Client` only exposes spec
|
||||
verbs, so vendor methods go through the underlying `ClientSession`. The
|
||||
`cast("types.ClientRequest", ...)` is needed because `send_request`'s
|
||||
`request` parameter is currently typed as the closed spec union; widening it
|
||||
(or adding `Client.send_request`) is tracked for beta.
|
||||
verbs, so vendor methods go through the underlying `ClientSession`.
|
||||
`send_request` accepts any `types.Request` subclass.
|
||||
|
||||
## Caveats
|
||||
|
||||
- The TypeScript SDK's equivalent example also shows a custom server→client
|
||||
**notification** (`acme/searchProgress`). The Python client currently drops
|
||||
any notification whose method is not in the spec registry
|
||||
(`ClientSession._on_notify` → `KeyError` → silent drop), and there is no
|
||||
`set_notification_handler` analogue. That half is omitted here.
|
||||
**notification** (`acme/searchProgress`). The Python client can observe
|
||||
vendor notifications via `NotificationBinding` (see
|
||||
`docs/advanced/extensions.md`). That half is omitted here because the
|
||||
lowlevel server has no surface for emitting vendor notifications yet.
|
||||
|
||||
## Spec
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue