Skip to content

Commit

Permalink
Use ETAG when poller is polling (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
typotter authored Sep 3, 2024
1 parent ba99154 commit 17820d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/Config/ConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public function reloadConfigurationIfExpired(): void
{
$flagCacheAge = $this->getCacheAgeSeconds();
if ($flagCacheAge === -1 || $flagCacheAge >= $this->cacheAgeLimit) {
$flagETag = $this->configurationStore->getMetadata(self::KEY_FLAG_ETAG);
$this->fetchAndStoreConfigurations($flagETag);
$this->reloadConfiguration();
}
}

Expand Down Expand Up @@ -179,4 +178,16 @@ private function fetchBanditsAsRequired(IBanditReferenceIndexer $indexer): void
$this->fetchAndStoreBandits();
}
}

/**
* @return void
* @throws HttpRequestException
* @throws InvalidApiKeyException
* @throws InvalidConfigurationException
*/
public function reloadConfiguration(): void
{
$flagETag = $this->configurationStore->getMetadata(self::KEY_FLAG_ETAG);
$this->fetchAndStoreConfigurations($flagETag);
}
}
2 changes: 1 addition & 1 deletion src/EppoClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static function init(
self::POLL_INTERVAL_MILLIS,
self::JITTER_MILLIS,
function () use ($configLoader) {
$configLoader->fetchAndStoreConfigurations();
$configLoader->reloadConfiguration();
}
);

Expand Down

0 comments on commit 17820d6

Please sign in to comment.