dispatchrun / dispatch-py

Python package to develop applications with Dispatch.
https://pypi.org/project/dispatch-py/
Apache License 2.0
54 stars 3 forks source link

Remote endpoints #134

Closed chriso closed 6 months ago

chriso commented 6 months ago

This PR reworks the Registry class so that it can be used to register and dispatch calls to functions hosted on remote endpoints.

from dispatch import Registry

remote = Registry("http://some.foreign.endpoint/")

@remote.function
def foo(bar: int) -> str: ...

You only need to register a stub for remote functions. You can then dispatch calls to them (e.g. foo.dispatch(bar)), and also use them within a local function/coroutine (e.g. await foo(bar)). Type checking works as expected in both cases.