[Feature]: Thread-safe Multi-Instance API Client with Configuration Isolation
还没有人认领这个 Issue。
评估
调研方向
首先映射顶层导出的对象、各个 API 处理器子模块和 HTTP 客户端入口点,以了解单例状态和配置的存放位置。检查 ListTerminalsProtocol workaround 和现有注解;完成的标准是独立配置可以并发工作,并且静态分析器能够理解客户端 API。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 68
- 派生
- 51
- 平均合并
- 2 小时 3 分钟
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Adyen/adyen-python-api-library 的其他 Issue
-
[Bug] api_*_version override has no effect on PAL-based service URLs可能已有人在做 @cobanfurkanx 于 8 天前认领。 未关闭Bug do not stale
难度 2/5 1-3 小时 新手友好度 75/100
-
Feature
难度 4/5 3-5 天 新手友好度 45/100
Adyen/adyen-python-api-library#487 · 1 条评论 · 1 个 reaction ·
-
[Test] Add baseUrl environment tests to all service test files可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭do not stale Test
难度 4/5 3-5 天 新手友好度 55/100
-
chore: consolidate package metadata into pyproject.toml (PEP 621)可能已有人在做 @erdemtuna 于 190 天前认领。 未关闭do not stale
难度 3/5 1-2 天 新手友好度 72/100
-
[Bug]: Unknown properties return None可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭do not stale
难度 2/5 1-3 小时 新手友好度 48/100
Adyen/adyen-python-api-library#397 · 2 条评论 ·
查看 Adyen/adyen-python-api-library 的全部 Issue
相似的 Issue
-
customer-reported question
难度 2/5 1-3 小时 新手友好度 62/100
Azure/azure-sdk-for-python#49548 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
btclib-org/btclib-wallet#409 ·
维护者通常 1 天内回复
-
Phase 2 PSA Capability & Career Profile
难度 2/5 1-3 小时 新手友好度 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 78/100
fastmachinelearning/hls4ml#1582 ·
维护者通常 3 天内回复
-
Sort models未关闭enhancement good first issue
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复