|
28 | 28 | from dispatch.sdk.v1.error_pb2 import Error
|
29 | 29 | from dispatch.sdk.v1.function_pb2 import RunRequest, RunResponse
|
30 | 30 | from dispatch.sdk.v1.poll_pb2 import PollResult
|
31 |
| -from dispatch.sdk.v1.status_pb2 import STATUS_OK |
| 31 | +from dispatch.sdk.v1.status_pb2 import ( |
| 32 | + STATUS_DNS_ERROR, |
| 33 | + STATUS_HTTP_ERROR, |
| 34 | + STATUS_INCOMPATIBLE_STATE, |
| 35 | + STATUS_OK, |
| 36 | + STATUS_TCP_ERROR, |
| 37 | + STATUS_TEMPORARY_ERROR, |
| 38 | + STATUS_THROTTLED, |
| 39 | + STATUS_TIMEOUT, |
| 40 | + STATUS_TLS_ERROR, |
| 41 | +) |
32 | 42 |
|
33 | 43 | from .client import EndpointClient
|
34 | 44 | from .server import DispatchServer
|
@@ -183,7 +193,18 @@ def make_request(call: Call) -> RunRequest:
|
183 | 193 | res = await self.run(call.endpoint, req)
|
184 | 194 |
|
185 | 195 | if res.status != STATUS_OK:
|
186 |
| - # TODO: emulate retries etc... |
| 196 | + if res.status in ( |
| 197 | + STATUS_TIMEOUT, |
| 198 | + STATUS_THROTTLED, |
| 199 | + STATUS_TEMPORARY_ERROR, |
| 200 | + STATUS_INCOMPATIBLE_STATE, |
| 201 | + STATUS_DNS_ERROR, |
| 202 | + STATUS_TCP_ERROR, |
| 203 | + STATUS_TLS_ERROR, |
| 204 | + STATUS_HTTP_ERROR, |
| 205 | + ): |
| 206 | + continue # emulate retries, without backoff for now |
| 207 | + |
187 | 208 | if (
|
188 | 209 | res.HasField("exit")
|
189 | 210 | and res.exit.HasField("result")
|
@@ -263,14 +284,19 @@ async def main(coro: Coroutine[Any, Any, None]) -> None:
|
263 | 284 | api = Service()
|
264 | 285 | app = Dispatch(reg)
|
265 | 286 | try:
|
| 287 | + print("Starting bakend") |
266 | 288 | async with Server(api) as backend:
|
| 289 | + print("Starting server") |
267 | 290 | async with Server(app) as server:
|
268 | 291 | # Here we break through the abstraction layers a bit, it's not
|
269 | 292 | # ideal but it works for now.
|
270 | 293 | reg.client.api_url.value = backend.url
|
271 | 294 | reg.endpoint = server.url
|
| 295 | + print("BACKEND:", backend.url) |
| 296 | + print("SERVER:", server.url) |
272 | 297 | await coro
|
273 | 298 | finally:
|
| 299 | + print("DONE!") |
274 | 300 | await api.close()
|
275 | 301 | # TODO: let's figure out how to get rid of this global registry
|
276 | 302 | # state at some point, which forces tests to be run sequentially.
|
|
0 commit comments