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

[REQ][csharp][restsharp] Option to construct RestClient with useClientFactory: true

Đang mở Phù hợp với người mới
#25,425 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, java
Lĩnh vực
api, backend

Hướng nghiên cứu

Đọc template ApiClient.mustache của trình tạo C# RestSharp và tìm nơi nó khởi tạo RestClient; sau đó lần theo các định nghĩa tùy chọn và bài kiểm thử của trình tạo đối với những tùy chọn ảnh hưởng đến đầu ra được tạo. Thêm tùy chọn useClientFactory không bật theo mặc định, với giá trị mặc định là false, và xác minh rằng đầu ra được tạo không thay đổi theo mặc định, còn khi bật tùy chọn thì truyền useClientFactory: true.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Enhancement: Feature
Is your feature request related to a problem? Please describe.

The restsharp ApiClient creates a new RestClient per request, and RestSharp creates a new HttpClient per RestClient. Under load this exhausts sockets (connections pile up in TIME_WAIT), the classic HttpClient-per-request problem.

Describe the solution you'd like

An opt-in generator option useClientFactory (default false, generated output unchanged) that passes useClientFactory: true to the RestClient constructor in ApiClient.mustache, so RestSharp reuses a cached HttpClient per base URL.

See useClientFactory

Describe alternatives you've considered

  • Custom templates via -t: ApiClient.mustache is a single ~600-line template, so users fork all of it to change one constructor argument and then drift from upstream fixes.
  • Caching the RestClient in ApiClient: a larger change to its lifetime and thread-safety.

Additional context

RestSharp's factory caches the HttpClient process-wide per base URL, so handler settings of the first RestClient (Proxy, ClientCertificates, RemoteCertificateValidationCallback, UseDefaultCredentials) apply to later ones. That is why the option should be opt-in.

cc @mandrean @shibayan @Blackclaws @lucamazzanti

Ngôn ngữ chính
Java
Star
26.8k
Fork
7.7k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
185

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 OpenAPITools/openapi-generator

Tất cả issue của OpenAPITools/openapi-generator

Issue tương tự

Thêm issue về Java

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.