[rb] implement client config class
User description
🔗 Related Issues
Addresses Ruby portion of #16269
💥 What does this PR do?
- Creates config class for customizing everything currently customizable about Default http client
- Allows passing in the client_config into the driver constructors which passes it to the Bridge constructor
- Bridge Constructor has to manage all the ways the parameters can be in conflict
🔧 Implementation Notes
Went with a Data instance based on its goal of immutability. I overrode the constructor so that it only allows keywords and they are all optional
PORO seemed overkill and Struct is too loose
💡 Additional Considerations
- My first thought was that we would be deprecating the existing http_client approach, but that only makes sense if net-http can do everything everyone needs it to do, and apparently there is a lot it can't do, so I guess we continue to allow people to also pass in an http_client? Or we figure out some kind of factory to use this client config with the various options?
- There are several additional things that can be modified here; we could add more to the client config:
- max redirects
- retries
- keep-alive timeout
- http version
- Finally, update #16472 to use this approach to support websocket values as well
🔄 Types of changes
- New feature (non-breaking change which adds functionality and tests!)
PR Type
Enhancement
Description
-
Introduces
ClientConfigimmutable data class for HTTP client customization -
Allows passing
client_configto driver constructors and bridge initialization -
Implements validation to prevent conflicting
http_clientandclient_configparameters -
Refactors bridge initialization with URL normalization and server URL handling
-
Adds comprehensive test coverage for new client config functionality
Diagram Walkthrough
flowchart LR
Driver["Driver Constructor"]
Bridge["Bridge Initialize"]
ClientConfig["ClientConfig Data Class"]
HttpClient["Http::Default Client"]
Driver -->|"client_config param"| Bridge
Bridge -->|"validates params"| ClientConfig
ClientConfig -->|"builds from config"| HttpClient
Bridge -->|"uses http_client"| HttpClient
File Walkthrough
| Relevant files | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Enhancement | |||||||||||
| Configuration changes | 1 files
| ||||||||||
| Tests | 1 files
| ||||||||||
| Documentation | 5 files
|
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
| Security Compliance | ||||
| 🟢 | No security concerns identifiedNo security vulnerabilities detected by AI analysis. Human verification advised for critical code. | |||
| Ticket Compliance | ||||
| 🟡 |
🎫 #5678
| |||
| 🟡 |
🎫 #1234
| |||
| Codebase Duplication Compliance | ||||
| ⚪ | Codebase context is not definedFollow the guide to enable codebase context checks. | |||
| Custom Compliance | ||||
| ⚪ | No custom compliance providedFollow the guide to enable custom compliance check. | |||
| ||||
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| Possible issue |
Avoid using shared global stateSet rb/lib/selenium/webdriver/remote/bridge.rb [676-688]
Suggestion importance[1-10]: 10__ Why: The suggestion correctly identifies a critical race condition caused by setting | High |
| High-level |
Avoid using global HTTP configurationThe configuration for Examples:rb/lib/selenium/webdriver/remote/bridge.rb [682-683]
Solution Walkthrough:Before:
After:
Suggestion importance[1-10]: 9__ Why: This suggestion correctly identifies a critical design flaw where per-driver configurations are set on global class variables, which will cause race conditions and incorrect behavior in common parallel execution scenarios. | High |
| General |
Improve clarity of error messageUpdate the error message in rb/lib/selenium/webdriver/remote/bridge.rb [690-696]
Suggestion importance[1-10]: 4__ Why: The suggestion correctly points out a misleading error message and proposes a clearer alternative, which improves developer experience. | Low |
| ||