Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Feature]: Thread-safe Multi-Instance API Client with Configuration Isolation

Đang mở
#388 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, payments

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 needs response
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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Adyen/adyen-python-api-library

Tất cả issue của Adyen/adyen-python-api-library

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.