Closed chriso closed 6 months ago
Users can dispatch a set of calls using the low-level Client:
Client
class Client: def dispatch(calls: Iterable[Call]) -> list[DispatchID])
We construct a Client instance when users use the FastAPI integration, but we don't currently export the client instance.
We provide sugar for dispatching a single call like so:
@dispatch.function def foo(bar: int): ... foo.dispatch(1) # sugar for: client.dispatch([foo.build_call(1)])
We don't provide any sugar for dispatching more than one call to a single function, or to many functions in the same batch.
This PR fixes the issue by providing a way to build and dispatch a batch of calls:
batch = dispatch.batch() batch.add(func1, *args, **kwargs) batch.add(func2, *args, **kwargs) batch.add(func3, *args, **kwargs) batch.dispatch()
Care has been taken to ensure that mypy will check that the types of args/kwargs match the specified function.
mypy
args
kwargs
Users can dispatch a set of calls using the low-level
Client
:We construct a
Client
instance when users use the FastAPI integration, but we don't currently export the client instance.We provide sugar for dispatching a single call like so:
We don't provide any sugar for dispatching more than one call to a single function, or to many functions in the same batch.
This PR fixes the issue by providing a way to build and dispatch a batch of calls:
Care has been taken to ensure that
mypy
will check that the types ofargs
/kwargs
match the specified function.