8000 feat: add odp config by andrewleap-optimizely · Pull Request #401 · optimizely/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

feat: add odp config #401

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 7 commits into from
Aug 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
make attributes private
  • Loading branch information
andrewleap-optimizely committed Aug 22, 2022
commit 7ca0a66699119068f2c0a556ee531a8e06d6e536
24 changes: 12 additions & 12 deletions optimizely/odp/odp_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(
api_host: Optional[str] = None,
segments_to_check: Optional[list[str]] = None
) -> None:
self.api_key = api_key
self.api_host = api_host
self.segments_to_check = segments_to_check or []
self._api_key = api_key
self._api_host = api_host
self._segments_to_check = segments_to_check or []
self.lock = Lock()

def update(self, api_key: Optional[str], api_host: Optional[str], segments_to_check: list[str]) -> bool:
Expand All @@ -53,27 +53,27 @@ def update(self, api_key: Optional[str], api_host: Optional[str], segments_to_ch
"""
updated = False
with self.lock:
if self.api_key != api_key or self.api_host != api_host or self.segments_to_check != segments_to_check:
self.api_key = api_key
self.api_host = api_host
self.segments_to_check = segments_to_check
if self._api_key != api_key or self._api_host != api_host or self._segments_to_check != segments_to_check:
self._api_key = api_key
self._api_host = api_host
self._segments_to_check = segments_to_check
updated = True

return updated

def get_api_host(self) -> Optional[str]:
with self.lock:
return self.api_host
return self._api_host

def get_api_key(self) -> Optional[str]:
with self.lock:
return self.api_key
return self._api_key

def get_segments_to_check(self) -> Optional[list[str]]:
def get_segments_to_check(self) -> list[str]:
with self.lock:
return self.segments_to_check.copy()
return self._segments_to_check.copy()

def odp_integrated(self) -> bool:
"""Returns True if ODP is integrated."""
with self.lock:
return self.api_key is not None and self.api_host is not None
return self._api_key is not None and self._api_host is not None
0