Skip to content

feat: implement asynchronous endpoint synchronization to marketplaces…#34

Merged
shubham3121 merged 2 commits intomainfrom
feat/sync-endpoints
Jan 28, 2026
Merged

feat: implement asynchronous endpoint synchronization to marketplaces…#34
shubham3121 merged 2 commits intomainfrom
feat/sync-endpoints

Conversation

@shubham3121
Copy link
Member

This pull request introduces functionality to synchronize published endpoints with external marketplaces, ensuring that all published endpoints are kept up-to-date across connected platforms. It adds a method to bulk sync endpoints at startup and provides supporting repository and API client enhancements to enable this feature.

Key changes include:

Endpoint Synchronization Logic:

  • Added a new sync_endpoints_to_marketplaces method to EndpointHandler, which groups published endpoints by marketplace and calls a new sync API for each, handling errors gracefully and logging results.
  • Introduced a helper function _sync_endpoints_safe in main.py that triggers endpoint synchronization at server startup in a fire-and-forget manner, ensuring the server remains available even if the sync fails or times out.
  • Modified the application lifespan in main.py to invoke the endpoint sync helper after tenant setup during startup.

Repository and API Enhancements:

  • Added get_published_endpoints to EndpointRepository, which retrieves all endpoints published to at least one marketplace, with related models, datasets, and policies eagerly loaded.
  • Implemented a sync_endpoints method in SyftHubClient to call the new bulk sync API on SyftHub, overwriting existing endpoints with the provided list.

Code Refactoring:

  • Refactored the payload-building logic for publishing endpoints into a dedicated _build_publish_payload method to avoid duplication and improve maintainability. [1] [2]
  • Added missing import for Any in handlers.py to support new type annotations.
  • Imported or_ from sqlmodel in repository.py to support the new query logic for fetching published endpoints.

… during app startup

- Add _sync_endpoints_safe function to handle endpoint synchronization during startup without blocking.
- Introduce sync_endpoints method in EndpointHandler to group and sync published endpoints to their respective marketplaces.
- Create _build_publish_payload method to streamline payload construction for endpoint publishing.
- Enhance EndpointRepository with get_published_endpoints method to retrieve published endpoints for a tenant.
@shubham3121 shubham3121 merged commit 476671f into main Jan 28, 2026
2 checks passed
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.

1 participant