-
Notifications
You must be signed in to change notification settings - Fork 36
feat: fetch timeout made configurable #411
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
Conversation
andrewleap-optimizely
left a comment
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.
Looks good! A couple minor suggestions.
Also can we add a test confirming the new settings get passed in appropriately?
| api_key: str, | ||
| api_host: str, | ||
| events: list[OdpEvent], | ||
| odp_event_timeout: Optional[int] = None) -> bool: |
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.
| odp_event_timeout: Optional[int] = None) -> bool: | |
| timeout: Optional[int] = None) -> bool: |
Seems like odp_event prefix is unnecessary in this context?
| def fetch_qualified_segments(self, user_key: str, user_value: str, options: list[str] | ||
| ) -> Optional[list[str]]: | ||
| def fetch_qualified_segments(self, user_key: str, user_value: str, options: list[str], | ||
| fetch_segments_timeout: Optional[int]) -> Optional[list[str]]: |
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.
| fetch_segments_timeout: Optional[int]) -> Optional[list[str]]: | |
| timeout: Optional[int]) -> Optional[list[str]]: |
fetch_segments is redundant in this context.
| def fetch_segments(self, api_key: str, api_host: str, user_key: str, | ||
| user_value: str, segments_to_check: list[str]) -> Optional[list[str]]: | ||
| user_value: str, segments_to_check: list[str], | ||
| fetch_segments_timeout: Optional[int] = None) -> Optional[list[str]]: |
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.
| fetch_segments_timeout: Optional[int] = None) -> Optional[list[str]]: | |
| timeout: Optional[int] = None) -> Optional[list[str]]: |
| fetch_segments_timeout: Optional[int] = None) -> Optional[list[str]]: | ||
| """ | ||
| Fetch segments from ODP GraphQL API. | ||
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.
Missing doc string for the new arg
optimizely/odp/odp_manager.py
Outdated
| self.segment_manager = OdpSegmentManager(segments_cache, logger=self.logger) | ||
|
|
||
| self.event_manager = self.event_manager or OdpEventManager(self.logger) | ||
| self.event_manager.odp_event_timeout = odp_event_timeout |
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.
How about we pass this in on initialization of the OdpEventManager?
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.
+1 Pass it down all the way to OdpEventApiManager and OdpSegmentApiManager?
jaeopt
left a comment
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.
A suggestion to pass down timeout while initialization. Other than that, it looks good.
| self.logger = logger or optimizely_logger.NoOpLogger() | ||
|
|
||
| def send_odp_events(self, api_key: str, api_host: str, events: list[OdpEvent]) -> bool: | ||
| def send_odp_events(self, |
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.
What about passing the timeout value when initializing? We do not need to send timeout for every event. It's not expected we need event-by-event control. Also a custom OdpEventApiManager can have own timeout control.
|
|
||
| def fetch_segments(self, api_key: str, api_host: str, user_key: str, | ||
| user_value: str, segments_to_check: list[str]) -> Optional[list[str]]: | ||
| user_value: str, segments_to_check: list[str], |
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.
same here. we may keep the timeout constant locally instead of passing timeout for each api call.
optimizely/odp/odp_manager.py
Outdated
| self.segment_manager = OdpSegmentManager(segments_cache, logger=self.logger) | ||
|
|
||
| self.event_manager = self.event_manager or OdpEventManager(self.logger) | ||
| self.event_manager.odp_event_timeout = odp_event_timeout |
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.
+1 Pass it down all the way to OdpEventApiManager and OdpSegmentApiManager?
andrewleap-optimizely
left a comment
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.
Just a couple more small suggestions. Also can we add one more test for Optimizely initialization with OptimizelySdkSettings and the two new parameters?
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None): | ||
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None, timeout: Optional[int] = None): | ||
| self.logger = logger or optimizely_logger.NoOpLogger() | ||
| self.timeout = timeout |
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.
| self.timeout = timeout | |
| self.timeout = timeout or OdpEventApiConfig.REQUEST_TIMEOUT |
Might as well just do this once.
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.
+1
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None): | ||
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None, timeout: Optional[int] = None): | ||
| self.logger = logger or optimizely_logger.NoOpLogger() | ||
| self.timeout = timeout |
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.
| self.timeout = timeout | |
| self.timeout = timeout or OdpSegmentApiConfig.REQUEST_TIMEOUT |
jaeopt
left a comment
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.
LGTM
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None): | ||
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None, timeout: Optional[int] = None): | ||
| self.logger = logger or optimizely_logger.NoOpLogger() | ||
| self.timeout = timeout |
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.
+1
andrewleap-optimizely
left a comment
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.
lgtm
Summary
sdk_settingsoptionTest plan
Ticket
FSSDK-8693