Skip to content

Commit

Permalink
remove connection id for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Jan 24, 2025
1 parent 78b8103 commit 5c69b7e
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 27 deletions.
3 changes: 1 addition & 2 deletions src/Client/DefaultRegistrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public function register(iterable $strategyHandlers): bool

$request = $request
->withHeader('x-unleash-appname', $this->configuration->getAppName())
->withHeader('x-unleash-sdk', $this->sdkName . ':' . $this->sdkVersion)
->withHeader('x-unleash-connection-id', $this->configuration->getConnectionId());
->withHeader('x-unleash-sdk', $this->sdkName . ':' . $this->sdkVersion);

try {
$response = $this->httpClient->sendRequest($request);
Expand Down
14 changes: 0 additions & 14 deletions src/Configuration/UnleashConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

final class UnleashConfiguration
{
private string $connectionId;

/**
* @param array<string,string> $headers
*/
Expand All @@ -49,7 +47,6 @@ public function __construct(
private MetricsBucketSerializer $metricsBucketSerializer = new DefaultMetricsBucketSerializer(),
) {
$this->contextProvider ??= new DefaultUnleashContextProvider();
$this->connectionId = Uuid::v4();
}

public function getCache(): CacheInterface
Expand Down Expand Up @@ -303,15 +300,4 @@ public function setMetricsBucketSerializer(MetricsBucketSerializer $metricsBucke

return $this;
}

public function getConnectionId(): string
{
$connectionId = $this->getCache()->get(CacheKey::CONNECTION_ID, $this->connectionId);
return is_string($connectionId) ? $connectionId : $this->connectionId;
}

public function updateCachedConnectionId(): void
{
$this->getCache()->set(CacheKey::CONNECTION_ID, $this->connectionId);
}
}
2 changes: 0 additions & 2 deletions src/Enum/CacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ final class CacheKey
public const string REGISTRATION = 'unleash.client.metrics.registration';

public const string FEATURES_RESPONSE = 'unleash.client.feature.response';

public const string CONNECTION_ID = 'unleash.client.connection.id';
}
4 changes: 1 addition & 3 deletions src/Repository/DefaultUnleashRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ private function setCache(array $features): void
$cache = $this->configuration->getCache();
$ttl = $this->configuration->getTtl();
$cache->set(CacheKey::FEATURES, $features, $ttl);
$this->configuration->updateCachedConnectionId();
}

/**
Expand Down Expand Up @@ -525,8 +524,7 @@ private function fetchFeatures(): array

$request = $request
->withHeader('x-unleash-appname', $this->configuration->getAppName())
->withHeader('x-unleash-sdk', $this->sdkName . ':' . $this->sdkVersion)
->withHeader('x-unleash-connection-id', $this->configuration->getConnectionId());
->withHeader('x-unleash-sdk', $this->sdkName . ':' . $this->sdkVersion);

try {
$response = $this->httpClient->sendRequest($request);
Expand Down
4 changes: 0 additions & 4 deletions src/UnleashBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ final class UnleashBuilder

private ?string $appName = null;

private string $connectionId;

private ?ClientInterface $httpClient = null;

private ?RequestFactoryInterface $requestFactory = null;
Expand Down Expand Up @@ -134,8 +132,6 @@ public function __construct()
$this->eventDispatcher = new EventDispatcher();
}

$this->connectionId = Uuid::v4();

$rolloutStrategyHandler = new GradualRolloutStrategyHandler(new MurmurHashCalculator());
$this->strategies = [
new DefaultStrategyHandler(),
Expand Down
2 changes: 0 additions & 2 deletions tests/Client/DefaultRegistrationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public function testRequestHeaders()
->setCache($this->getCache())
->setHeaders([
'Some-Header' => 'some-value',
'x-unleash-connection-id' => 'should not override',
])->setCache($this->getCache());

$instance = new DefaultRegistrationService(
Expand All @@ -155,6 +154,5 @@ public function testRequestHeaders()
self::assertSame('some-value', $request->getHeaderLine('Some-Header'));
self::assertEquals('customAppName', $request->getHeaderLine('x-unleash-appname'));
self::assertStringStartsWith('unleash-client-php:', $request->getHeaderLine('x-unleash-sdk'));
self::assertStringMatchesFormat('%s-%s-%s-%s-%s', $request->getHeaderLine('x-unleash-connection-id'));
}
}

0 comments on commit 5c69b7e

Please sign in to comment.