Skip to content

Endpoint #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Endpoint #135

wants to merge 1 commit into from

Conversation

chriso
Copy link
Contributor

@chriso chriso commented Mar 22, 2024

This PR changes the import scheme so that the construction of local and remote endpoints is clearer.

For remote endpoints:

from dispatch.remote import Endpoint

remote = Endpoint(url)

@remote.function
def my_remote_func(): ...

For local endpoints (e.g. using FastAPI):

from fastapi import FastAPI
from dispatch.fastapi import Endpoint

app = FastAPI()
dispatch = Endpoint(app)

@dispatch.function
def my_local_func(): ...

Previously you had from dispatch.fastapi import Dispatch for local endpoints, and from dispatch import Registry for remote endpoints (#134).

With this PR we avoid using the ambiguous Dispatch and Registry names, and the ambiguous top-level namespace (from dispatch import $thing).

I've maintained backward compatibility by creating a dispatch.fastapi.{Dispatch => Endpoint} alias (so from dispatch.fastapi import Dispatch continues to work).

@chriso chriso self-assigned this Mar 22, 2024
@chriso chriso closed this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants