[Feature]: Thread-safe Multi-Instance API Client with Configuration Isolation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu bằng cách lập bản đồ các đối tượng được export ở cấp cao nhất, các submodule handler API riêng lẻ và các entry point của HTTP client để hiểu trạng thái singleton và cấu hình được lưu giữ ở đâu. Xem xét workaround của ListTerminalsProtocol và các annotation hiện có; hoàn thành có nghĩa là các cấu hình độc lập hoạt động đồng thời và các trình phân tích tĩnh có thể hiểu API của client.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Feature summary
Multi‑instance, thread‑safe API client with better typing
Problem statement
Background
The current Python client uses a singleton pattern for each API handler and the HTTP client. In multithreaded environments (e.g., UWSGI) this leads to thread‑safety issues and makes it impossible to use different credentials/settings for separate services (e.g., ECOM vs. POS).
A workaround is already in place: importing individual API parts from submodules and instantiating a separate HTTP client for each use‑case. However, the library’s interface still encourages the global singleton, which is not safe.
Proposed improvements
| Area | Desired change |
|---|---|
| Instance isolation | Remove the singleton pattern and allow callers to create multiple independent client instances. Each instance should accept its own configuration (API endpoint, authentication keys, HTTP client, etc.). |
| Documentation | Clearly document that the top‑level exported objects are global singletons and discourage their use in multi‑tenant or concurrent workflows. Provide examples of per‑instance creation. |
| Thread safety | Ensure no shared mutable state lives inside the client or its handler objects, so concurrent requests with different configs are safe. |
| Type hints | Improve static typing: • Functions that currently return AdyenResult | None | Unknown actually raise inside helper functions. Either raise the exception directly or return a clear Union with explicit error types. • Provide type stubs / .pyi files or refined type annotations so tools like basedpyright and mypy can understand the API signatures. • Example: Replace the ad‑hoc ListTerminalsProtocol workaround with a real protocol exposed in the library. |
My comments (for reference)
- The library is generated via an API generator, so a complete rewrite is not realistic.
- Instantiating small objects in Python has negligible memory overhead—no performance penalty.
- I am available for hire, on a consulting basis.
Proposed solution
Goal: Get a library that supports multiple concurrent clients with distinct configurations while providing robust typing for static analysis tools. This solves the thread‑safety problem and makes the ECOM/POS multi‑tenant use‑case straightforward.
Alternatives considered
No response
Additional context
No response
- Ngôn ngữ chính
- Python
- Star
- 68
- Fork
- 51
- Merge trung bình
- 2 giờ 3 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Adyen/adyen-python-api-library
-
[Bug] api_*_version override has no effect on PAL-based service URLsCó thể đã có người làm @cobanfurkanx đã nhận 9 ngày trước. Đang mởBug do not stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
[Feature]: Foreign Exchange APIĐang mởFeature
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Adyen/adyen-python-api-library#487 · 1 bình luận · 1 reaction ·
-
[Test] Add baseUrl environment tests to all service test filesCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdo not stale Test
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
chore: consolidate package metadata into pyproject.toml (PEP 621)Có thể đã có người làm @erdemtuna đã nhận 191 ngày trước. Đang mởdo not stale
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
-
[Bug]: Unknown properties return NoneCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdo not stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
Adyen/adyen-python-api-library#397 · 2 bình luận ·
Tất cả issue của Adyen/adyen-python-api-library
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
huggingface/sentence-transformers#4186 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
documentation good first issue
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
sujithputta02/Esapay#13 ·
-
bot-triaged module: correctness (silent) module: mps module: NaNs and Infs triage review
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
README: CI link/badge checkĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
SCIInstitute/SCIRun#2842 ·
Maintainer thường phản hồi trong vòng 3 ngày