Skip to content

feat(rest): add faraday_config option to client configuration#1284

Open
aandreassa wants to merge 1 commit intomainfrom
faraday-cfg
Open

feat(rest): add faraday_config option to client configuration#1284
aandreassa wants to merge 1 commit intomainfrom
faraday-cfg

Conversation

@aandreassa
Copy link
Copy Markdown
Contributor

Summary

Addresses issue googleapis/ruby-core-libraries#57.

While gapic-common already supports yielding the Faraday::Connection inside ClientStub, this hook was unreachable from auto-generated client libraries. This PR exposes that capability to the public client layer, enabling advanced HTTP customization like mTLS client certificate configuration.

Design

Instead of forwarding blocks through the client constructors (which collides with the existing configuration blocks), we introduce a config.faraday_config attribute.

This approach isolates transport specific details, allows clean automated propagation to internal subclients (LROs and mixins), and has a respond_to? check to preserve perfect backward compatibility with legacy gems versions.

Example Usage

client = Google::Cloud::Language::V1::LanguageService::Rest::Client.new do |config|
  config.faraday_config = ->(conn) do
    conn.ssl.client_cert = OpenSSL::X509::Certificate.new cert_pem
    conn.ssl.client_key  = OpenSSL::PKey::RSA.new key_pem
  end
end

Exposes the internal Faraday::Connection customization hook to the public client layer. This enables advanced HTTP setup, such as mTLS client certificate configuration.

Instead of forwarding blocks through the client constructors (which collides with the existing configuration blocks), we introduced a config.faraday_config attribute.

This approach isolates transport specific details, allows clean automated propagation to internal subclients (LROs and mixins), and uses a standard respond_to? check to preserve perfect backward compatibility with legacy external gems.

Example Usage

```ruby
client = Google::Cloud::Language::V1::LanguageService::Rest::Client.new do |config|
  config.faraday_config = ->(conn) do
    conn.ssl.client_cert = OpenSSL::X509::Certificate.new cert_pem
    conn.ssl.client_key  = OpenSSL::PKey::RSA.new key_pem
  end
end
```
@aandreassa aandreassa marked this pull request as ready for review May 6, 2026 02:24
@aandreassa aandreassa requested a review from a team as a code owner May 6, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant