-
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
Changes from 14 commits
d68bec0
7c9a7ca
c23b314
da97899
6e5c853
7ff3e3d
5b1951a
4c8ad4c
8ad739f
535ba82
db878c7
75f08ca
c83c966
32618ed
48bcbe3
7546a40
1c0778d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -43,14 +43,19 @@ class OdpEventApiManager: | |||||
| def __init__(self, logger: Optional[optimizely_logger.Logger] = None): | ||||||
| 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, | ||||||
| api_key: str, | ||||||
| api_host: str, | ||||||
| events: list[OdpEvent], | ||||||
| odp_event_timeout: Optional[int] = None) -> bool: | ||||||
|
||||||
| odp_event_timeout: Optional[int] = None) -> bool: | |
| timeout: Optional[int] = None) -> bool: |
Seems like odp_event prefix is unnecessary in this context?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,8 @@ def __init__( | |
| segments_cache: Optional[OptimizelySegmentsCache] = None, | ||
| segment_manager: Optional[OdpSegmentManager] = None, | ||
| event_manager: Optional[OdpEventManager] = None, | ||
| fetch_segments_timeout: Optional[int] = None, | ||
| odp_event_timeout: Optional[int] = None, | ||
| logger: Optional[optimizely_logger.Logger] = None | ||
| ) -> None: | ||
|
|
||
|
|
@@ -42,6 +44,7 @@ def __init__( | |
|
|
||
| self.segment_manager = segment_manager | ||
| self.event_manager = event_manager | ||
| self.fetch_segments_timeout = fetch_segments_timeout | ||
|
|
||
| if not self.enabled: | ||
| self.logger.info('ODP is disabled.') | ||
|
|
@@ -56,6 +59,7 @@ def __init__( | |
| 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 | ||
|
||
| self.segment_manager.odp_config = self.odp_config | ||
|
|
||
| def fetch_qualified_segments(self, user_id: str, options: list[str]) -> Optional[list[str]]: | ||
|
|
@@ -66,7 +70,7 @@ def fetch_qualified_segments(self, user_id: str, options: list[str]) -> Optional | |
| user_key = OdpManagerConfig.KEY_FOR_USER_ID | ||
| user_value = user_id | ||
|
|
||
| return self.segment_manager.fetch_qualified_segments(user_key, user_value, options) | ||
| return self.segment_manager.fetch_qualified_segments(user_key, user_value, options, self.fetch_segments_timeout) | ||
|
|
||
| def identify_user(self, user_id: str) -> None: | ||
| if not self.enabled or not self.event_manager: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -112,7 +112,8 @@ def __init__(self, logger: Optional[optimizely_logger.Logger] = None): | |||||
| self.logger = logger or optimizely_logger.NoOpLogger() | ||||||
|
|
||||||
| 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]]: | ||||||
|
||||||
| fetch_segments_timeout: Optional[int] = None) -> Optional[list[str]]: | |
| 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.
Missing doc string for the new arg
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,8 +38,8 @@ def __init__( | |||||
| self.logger = logger or optimizely_logger.NoOpLogger() | ||||||
| self.api_manager = api_manager or OdpSegmentApiManager(self.logger) | ||||||
|
|
||||||
| 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]]: | ||||||
|
||||||
| fetch_segments_timeout: Optional[int]) -> Optional[list[str]]: | |
| timeout: Optional[int]) -> Optional[list[str]]: |
fetch_segments is redundant in this context.
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.