Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit d1b4fa7

Browse files
feat: [default polling to 10 seconds from 5 minutes; add configurable value] (FF-2686) (#60)
* feat: [default polling to 10 seconds from 5 minutes; add configurable value] (FF-2686) * leave default at 5 min; add comment for breaking change in future * add config for jitter * tox
1 parent c015c4f commit d1b4fa7

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ The `init` function accepts the following optional configuration arguments.
8181
| ------ | ----- | ----- | ----- |
8282
| **`assignment_logger`** | [AssignmentLogger](https://github.com/Eppo-exp/python-sdk/blob/ebc1a0b781769fe9d2e2be6fc81779eb8685a6c7/eppo_client/assignment_logger.py#L6-L10) | A callback that sends each assignment to your data warehouse. Required only for experiment analysis. See [example](#assignment-logger) below. | `None` |
8383
| **`is_graceful_mode`** | bool | When true, gracefully handles all exceptions within the assignment function and returns the default value. | `True` |
84-
84+
| **`poll_interval_seconds`** | int | The interval in seconds at which the SDK polls for configuration updates. | `300` |
85+
| **`poll_jitter_seconds`** | int | The jitter in seconds to add to the poll interval. | `30` |
8586

8687
## Assignment logger
8788

eppo_client/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def init(config: Config) -> EppoClient:
4848
__client = EppoClient(
4949
config_requestor=config_requestor,
5050
assignment_logger=assignment_logger,
51+
poll_interval_seconds=config.poll_interval_seconds,
52+
poll_jitter_seconds=config.poll_jitter_seconds,
5153
is_graceful_mode=is_graceful_mode,
5254
)
5355
return __client

eppo_client/client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414
from eppo_client.configuration_requestor import (
1515
ExperimentConfigurationRequestor,
1616
)
17-
from eppo_client.constants import POLL_INTERVAL_MILLIS, POLL_JITTER_MILLIS
1817
from eppo_client.models import VariationType
1918
from eppo_client.poller import Poller
2019
from eppo_client.sharders import MD5Sharder
2120
from eppo_client.types import Attributes, ValueType
2221
from eppo_client.validation import validate_not_blank
2322
from eppo_client.eval import FlagEvaluation, Evaluator, none_result
2423
from eppo_client.version import __version__
24+
from eppo_client.constants import (
25+
POLL_INTERVAL_SECONDS_DEFAULT,
26+
POLL_JITTER_SECONDS_DEFAULT,
27+
)
2528

2629

2730
logger = logging.getLogger(__name__)
@@ -33,13 +36,15 @@ def __init__(
3336
config_requestor: ExperimentConfigurationRequestor,
3437
assignment_logger: AssignmentLogger,
3538
is_graceful_mode: bool = True,
39+
poll_interval_seconds: int = POLL_INTERVAL_SECONDS_DEFAULT,
40+
poll_jitter_seconds: int = POLL_JITTER_SECONDS_DEFAULT,
3641
):
3742
self.__config_requestor = config_requestor
3843
self.__assignment_logger = assignment_logger
3944
self.__is_graceful_mode = is_graceful_mode
4045
self.__poller = Poller(
41-
interval_millis=POLL_INTERVAL_MILLIS,
42-
jitter_millis=POLL_JITTER_MILLIS,
46+
interval_millis=poll_interval_seconds * 1000,
47+
jitter_millis=poll_jitter_seconds * 1000,
4348
callback=config_requestor.fetch_and_store_configurations,
4449
)
4550
self.__poller.start()

eppo_client/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
from eppo_client.assignment_logger import AssignmentLogger
22
from eppo_client.base_model import SdkBaseModel
3-
43
from eppo_client.validation import validate_not_blank
4+
from eppo_client.constants import (
5+
POLL_INTERVAL_SECONDS_DEFAULT,
6+
POLL_JITTER_SECONDS_DEFAULT,
7+
)
58

69

710
class Config(SdkBaseModel):
811
api_key: str
912
base_url: str = "https://fscdn.eppo.cloud/api"
1013
assignment_logger: AssignmentLogger
1114
is_graceful_mode: bool = True
15+
poll_interval_seconds: int = POLL_INTERVAL_SECONDS_DEFAULT
16+
poll_jitter_seconds: int = POLL_JITTER_SECONDS_DEFAULT
1217

1318
def _validate(self):
1419
validate_not_blank("api_key", self.api_key)

eppo_client/constants.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# poller
2-
SECOND_MILLIS = 1000
3-
MINUTE_MILLIS = 60 * SECOND_MILLIS
4-
POLL_JITTER_MILLIS = 30 * SECOND_MILLIS
5-
POLL_INTERVAL_MILLIS = 5 * MINUTE_MILLIS
2+
# We accidently shipped Python with a 5 minute poll interval.
3+
# Customers can set the poll interval to 30 seconds to match the behavior of the other server SDKs.
4+
# Please change this to 30 seconds when ready to bump to 4.0.
5+
POLL_JITTER_SECONDS_DEFAULT = 30 # 30 seconds
6+
POLL_INTERVAL_SECONDS_DEFAULT = 5 * 60 # 5 minutes

eppo_client/version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
__version__ = "3.4.0"
1+
# Note to developers: When ready to bump to 4.0, please change
2+
# the `POLL_INTERVAL_SECONDS` constant in `eppo_client/constants.py`
3+
# to 30 seconds to match the behavior of the other server SDKs.
4+
__version__ = "3.5.0"

0 commit comments

Comments
 (0)