-
Notifications
You must be signed in to change notification settings - Fork 54
chore: Allow individual http settings in fdv2 #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
673a30e
chore: Allow individual http settings in fdv2
jsonbailey 73cb0af
simplify new_http_client parameters
jsonbailey 3bcc1f8
fix tests
jsonbailey 07f2d3c
Merge branch 'main' into jb/support-builder-level-config-fdv2
jsonbailey 1d78cc6
Merge branch 'main' into jb/support-builder-level-config-fdv2
jsonbailey dc598f8
address feedback and attempt to fix contract tests
jsonbailey c8e162b
empty to trigger clean ci run
jsonbailey c33b4d8
fix failing test
jsonbailey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
lib/ldclient-rb/impl/data_system/data_source_builder_common.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "ldclient-rb/impl/data_system/http_config_options" | ||
|
|
||
| module LaunchDarkly | ||
| module Impl | ||
| module DataSystem | ||
| # | ||
| # DataSourceBuilderCommon is a mixin that provides common HTTP configuration | ||
| # setters for data source builders (polling and streaming). | ||
| # | ||
| # Each builder that includes this module must define a DEFAULT_BASE_URI constant. | ||
| # | ||
| module DataSourceBuilderCommon | ||
| # | ||
| # Sets the base URI for HTTP requests. | ||
| # | ||
| # @param uri [String] | ||
| # @return [self] | ||
| # | ||
| def base_uri(uri) | ||
| @base_uri = uri | ||
| self | ||
| end | ||
|
|
||
| # | ||
| # Sets a custom socket factory for HTTP connections. | ||
| # | ||
| # @param factory [Object] | ||
| # @return [self] | ||
| # | ||
| def socket_factory(factory) | ||
| @socket_factory = factory | ||
| self | ||
| end | ||
|
|
||
| # | ||
| # Sets the read timeout for HTTP connections. | ||
| # | ||
| # @param timeout [Float] Timeout in seconds | ||
| # @return [self] | ||
| # | ||
| def read_timeout(timeout) | ||
| @read_timeout = timeout | ||
| self | ||
| end | ||
|
|
||
| # | ||
| # Sets the connect timeout for HTTP connections. | ||
| # | ||
| # @param timeout [Float] Timeout in seconds | ||
| # @return [self] | ||
| # | ||
| def connect_timeout(timeout) | ||
| @connect_timeout = timeout | ||
| self | ||
| end | ||
|
|
||
| private | ||
|
jsonbailey marked this conversation as resolved.
Outdated
|
||
|
|
||
| # | ||
| # Builds an HttpConfigOptions instance from the current builder settings. | ||
| # Uses self.class::DEFAULT_BASE_URI if base_uri was not explicitly set. | ||
| # Read/connect timeouts default to HttpConfigOptions defaults if not set. | ||
| # | ||
| # @return [HttpConfigOptions] | ||
| # | ||
| def build_http_config | ||
| HttpConfigOptions.new( | ||
| base_uri: @base_uri || self.class::DEFAULT_BASE_URI, | ||
| socket_factory: @socket_factory, | ||
| read_timeout: @read_timeout, | ||
| connect_timeout: @connect_timeout | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module LaunchDarkly | ||
| module Impl | ||
| module DataSystem | ||
| # | ||
| # HttpConfigOptions contains HTTP connection configuration settings. | ||
| # This class is created by data source builders and passed to v2 Requesters/DataSources. | ||
| # | ||
| class HttpConfigOptions | ||
| # Generic HTTP defaults - base URIs live in the respective builders | ||
| DEFAULT_READ_TIMEOUT = 10 | ||
| DEFAULT_CONNECT_TIMEOUT = 2 | ||
|
|
||
| attr_reader :base_uri, :socket_factory, :read_timeout, :connect_timeout | ||
|
|
||
| # | ||
| # @param base_uri [String] The base URI for HTTP requests | ||
| # @param socket_factory [Object, nil] Optional socket factory for custom connections | ||
| # @param read_timeout [Float, nil] Read timeout in seconds (defaults to DEFAULT_READ_TIMEOUT) | ||
| # @param connect_timeout [Float, nil] Connect timeout in seconds (defaults to DEFAULT_CONNECT_TIMEOUT) | ||
| # | ||
| def initialize(base_uri:, socket_factory: nil, read_timeout: nil, connect_timeout: nil) | ||
| @base_uri = base_uri | ||
| @socket_factory = socket_factory | ||
| @read_timeout = read_timeout || DEFAULT_READ_TIMEOUT | ||
| @connect_timeout = connect_timeout || DEFAULT_CONNECT_TIMEOUT | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this line has made the
clientparameter unused. Were we ever providing this and are we appropriately capturing that level of control that we previously had?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client was actually unused in the EventSender initializer and it just constructed its own client.