rpc
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| RpcSocket pyt3client.native.rpc Requests and streams over one Effect RPC WebSocket; many may run at once. |
||
| T3RpcError pyt3client.errors A native RPC failed: the server ended the request with a failure, or the socket closed. |
||
| _CauseDie pyt3client.native.rpc |
||
| _CauseFail pyt3client.native.rpc |
||
| _CauseInterrupt pyt3client.native.rpc |
||
| _Chunk pyt3client.native.rpc |
||
| _Closed pyt3client.native.rpc The socket ended; every open request fails with `error`. |
||
| _Defect pyt3client.native.rpc |
||
| _Exit pyt3client.native.rpc |
||
| _ExitFailure pyt3client.native.rpc |
||
| _ExitSuccess pyt3client.native.rpc |
||
| _Frame pyt3client.native.rpc |
||
| _Ping pyt3client.native.rpc |
||
| _Pong pyt3client.native.rpc |
||
| _ProtocolError pyt3client.native.rpc |
🛈 DocStrings¶
Effect RPC over a WebSocket, the protocol of T3 Code's native clients.
Frames are JSON objects tagged by _tag (upstream, vendored Effect:
.repos/effect/packages/effect/src/rpc/RpcMessage.ts):
- client -> server:
Request {id, tag, payload, headers};Ack {requestId}after each chunk of a stream (the server sends the next chunk once acked);Interrupt {requestId, interruptors}to end a request early;Ping. - server -> client:
Chunk {requestId, values}(items of a stream);Exit {requestId, exit}, whereexitis{_tag: "Success", value}or{_tag: "Failure", cause: [...]};Defect {defect}andClientProtocolError, which end every request;Pong.
Methods (tag) and their payloads are in upstream packages/contracts/src/rpc.ts
and orchestrationV2.ts (ORCHESTRATION_V2_WS_METHODS).
KEEPALIVE_SECONDS
module-attribute
¶
KEEPALIVE_SECONDS = 15.0
Interval of RPC Pings, which keep idle subscriptions open through proxies.
RpcSocket
¶
Requests and streams over one Effect RPC WebSocket; many may run at once.
Use RpcSocket.connect(url). Each request gets its own id; a reader task routes
the server's frames to the request they answer.
Source code in src/pyt3client/native/rpc.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
call
async
¶
call(tag: str, payload: Mapping[str, JsonValue]) -> JsonValue
Send a request and return its result.
Raises:
| Type | Description |
|---|---|
T3RpcError
|
The request failed, or the socket closed before it ended. |
Source code in src/pyt3client/native/rpc.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
connect
async
classmethod
¶
connect(url: str) -> AsyncGenerator[RpcSocket]
Open the socket at url (with its wsTicket) and close it on exit.
Source code in src/pyt3client/native/rpc.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
stream
async
¶
stream(tag: str, payload: Mapping[str, JsonValue]) -> AsyncIterator[JsonValue]
Send a streaming request and yield its items until the server ends it.
Leaving the loop early interrupts the request on the server.
Raises:
| Type | Description |
|---|---|
T3RpcError
|
The request failed, or the socket closed before it ended. |
Source code in src/pyt3client/native/rpc.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |