Add Area-based Pool logic for regional URL cycling#2
Merged
Conversation
- Add Area enum (US, EU, AP, CN) for global regions - Add Pool class for managing regional URLs with automatic cycling - Add DNS-based resolver for selecting best available domain (sync and async) - Add next_region() for cycling through region prefixes on failure - Add select_best_domain() for DNS-based domain selection - Support both agora.io and sd-rtn.com domain suffixes - Export domain module from core and main package Based on agora-rest-client-go/agora/domain implementation Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
⚙️ Control Options:
|
- Create AgoraPool that wraps Agora with domain pool - Create AsyncAgoraPool that wraps AsyncAgora with domain pool - Automatically use pool's current URL as base URL - Expose pool, next_region(), select_best_domain(), get_current_url() methods - Export AgoraPool and AsyncAgoraPool from main package Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
- Agora and AsyncAgora now extend base classes instead of duplicating code - Export only Agora/AsyncAgora (with pool support) from main package - Add edited files to .fernignore to prevent Fern overwriting Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Area-based Pool logic for regional URL cycling in the Python SDK, mirroring the implementation from the Go SDK PR.
Key additions:
Areaenum (US, EU, AP, CN) representing global regionsPoolclass for managing regional URLs with automatic cycling and DNS-based domain selectionselect_best_domain) and async (select_best_domain_async) DNS resolutionagora.ioandsd-rtn.comdomain suffixesnext_region()for cycling through region prefixes on failureAgoraandAsyncAgoraclients now include domain pool integrationUpdates since last revision
Refactored to extend base classes instead of duplicating code:
Agoranow extends the baseAgoraclass with domain pool supportAsyncAgoranow extends the baseAsyncAgoraclass with domain pool support.fernignoreto prevent Fern from overwriting custom codeUsage:
from agoraio import Agora, AsyncAgora, AreaReview & Testing Checklist for Human
Agora/AsyncAgoraexports are replaced with pool-enabled versions. Verify this doesn't break existing consumers who don't want pool functionality (they must now provideareaparameter)_client_wrapper._base_urlto update the base URL. Verify this internal access pattern is acceptable._domain_need_update()check happens outside the lock before acquiring it inselect_best_domain(). Verify this double-checked locking pattern is acceptable.select_best_domain_asyncuses a synchronousthreading.Lockinside an async method, which could block the event loop. Consider if this should useasyncio.Lockinstead.Test plan:
Notes
Link to Devin run: https://app.devin.ai/sessions/ece6fb9b8ad84ec68720a1bcd7d64f93
Requested by: @fern-support