Skip to content

fix: httpClient being created for every request#4

Merged
petruki merged 1 commit into
masterfrom
bugfix
May 12, 2026
Merged

fix: httpClient being created for every request#4
petruki merged 1 commit into
masterfrom
bugfix

Conversation

@petruki
Copy link
Copy Markdown
Member

@petruki petruki commented May 12, 2026

This pull request introduces improvements to the HTTP client management and request handling logic in the client package. The main changes add thread-safe, lazy initialization and caching for the HTTP client, and ensure safer handling of nil entries in request payloads.

HTTP client management improvements:

  • Added a mutex (httpClientMu) and a cached HTTP client field (httpClient_) to the Client struct to support thread-safe, lazy initialization and reuse of the http.Client instance. (client.go client.goR21-R23)
  • Modified the httpClient() method to use the mutex and cache, ensuring only one HTTP client is created and reused across requests. (remote.go [1] [2]
  • Imported the net/http package to support the new HTTP client logic. (client.go client.goR4)

Request payload safety:

  • Updated the checkCriteria method to ensure that the entries field in the request payload is always a valid (non-nil) slice, preventing potential issues when the field is nil. (remote.go remote.goR97-R106)

@petruki petruki self-assigned this May 12, 2026
@petruki petruki added bug Something isn't working patch Patches a code issue or dependency vulnerability/compatibility ai-assisted Indicates that AI tools were used to assist this with this change labels May 12, 2026
@sonarqubecloud
Copy link
Copy Markdown

@petruki petruki merged commit 22f178a into master May 12, 2026
7 checks passed
@petruki petruki deleted the bugfix branch May 12, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change bug Something isn't working patch Patches a code issue or dependency vulnerability/compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant