Skip to content

Commit f158cf0

Browse files
committed
merged with latest release
1 parent 29a6dce commit f158cf0

32 files changed

+1131
-57
lines changed

CHANGES.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
- BREAKING CHANGE: Removed support from versions older than PHP 7.4.
33
- BREAKING CHANGE: Added support for Multiple Factory Instantiation.
44

5+
7.2.0 (Jan 24, 2024)
6+
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
7+
- Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
8+
- getTreatmentsByFlagSet and getTreatmentsByFlagSets
9+
- getTreatmentWithConfigByFlagSets and getTreatmentsWithConfigByFlagSets
10+
- Added `defaultTreatment` and `sets` properties to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager.
11+
12+
7.1.8 (Jul 24, 2023)
13+
- Fixed input validation for empty keys.
14+
515
7.1.7 (May 16, 2023)
616
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and phpdoc comments.
717
- Fixed php 8.2 warnings in code.

src/SplitIO/Component/Cache/Pool.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ public function expireKey($key, $ttl)
8383
{
8484
return $this->adapter->expireKey($key, $ttl);
8585
}
86+
87+
public function sMembers($key)
88+
{
89+
return $this->adapter->sMembers($key);
90+
}
8691
}

src/SplitIO/Component/Cache/SplitCache.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class SplitCache implements SplitCacheInterface
99

1010
const KEY_TRAFFIC_TYPE_CACHED = 'SPLITIO.trafficType.{trafficTypeName}';
1111

12+
const KEY_FLAG_SET_CACHED = 'SPLITIO.flagSet.{set}';
13+
1214
/**
1315
* @var \SplitIO\Component\Cache\Pool
1416
*/
@@ -37,6 +39,11 @@ private static function getCacheKeyForSplit($splitName)
3739
return str_replace('{splitName}', $splitName, self::KEY_SPLIT_CACHED_ITEM);
3840
}
3941

42+
private static function getCacheKeyForFlagSet($flagSet)
43+
{
44+
return str_replace('{set}', $flagSet, self::KEY_FLAG_SET_CACHED);
45+
}
46+
4047
private static function getSplitNameFromCacheKey($key)
4148
{
4249
$cacheKeyPrefix = self::getCacheKeyForSplit('');
@@ -87,6 +94,22 @@ public function getSplitNames()
8794
return array_map([self::class, 'getSplitNameFromCacheKey'], $splitKeys);
8895
}
8996

97+
/**
98+
* @param array(string) List of flag set names
99+
* @return array(string) List of all feature flag names by flag sets
100+
*/
101+
public function getNamesByFlagSets($flagSets)
102+
{
103+
$toReturn = array();
104+
if (empty($flagSets)) {
105+
return $toReturn;
106+
}
107+
foreach ($flagSets as $flagSet) {
108+
$toReturn[$flagSet] = $this->cache->sMembers(self::getCacheKeyForFlagSet($flagSet));
109+
}
110+
return $toReturn;
111+
}
112+
90113
/**
91114
* @return array(string) List of all split JSON strings
92115
*/

src/SplitIO/Component/Cache/SplitCacheInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ public function getChangeNumber();
1313
* @return string JSON representation
1414
*/
1515
public function getSplit($splitName);
16+
17+
/**
18+
* @param array(string) List of flag set names
19+
* @return array(string) List of all feature flag names by flag sets
20+
*/
21+
public function getNamesByFlagSets($flagSets);
1622
}

src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ public function rightPushQueue($queueName, $item);
3737
* @return boolean
3838
*/
3939
public function expireKey($key, $ttl);
40+
41+
/**
42+
* @param string $key
43+
* @return mixed
44+
*/
45+
public function sMembers($key);
4046
}

src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ public function isOnList($key, $value)
184184
return $this->client->sIsMember($key, $value);
185185
}
186186

187+
/**
188+
* @param string $key
189+
* @return mixed
190+
*/
191+
public function sMembers($key)
192+
{
193+
return $this->client->smembers($key);
194+
}
195+
187196
public function getKeys($pattern = '*')
188197
{
189198
$keys = $this->client->keys($pattern);

src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,20 @@ public function expireKey($key, $ttl)
123123
return false;
124124
}
125125
}
126+
127+
/**
128+
* @param string $key
129+
* @return mixed
130+
*/
131+
public function sMembers($key)
132+
{
133+
try {
134+
return $this->cacheAdapter->sMembers($key);
135+
} catch (\Exception $e) {
136+
Context::getLogger()->critical("An error occurred performing SMEMBERS for " . $key);
137+
Context::getLogger()->critical($e->getMessage());
138+
Context::getLogger()->critical($e->getTraceAsString());
139+
return array();
140+
}
141+
}
126142
}

src/SplitIO/Grammar/Split.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Split
3131
private $trafficAllocationSeed = null;
3232

3333
private $configurations = null;
34+
private $sets = null;
3435

3536
public function __construct(array $split)
3637
{
@@ -50,6 +51,7 @@ public function __construct(array $split)
5051
$split['trafficAllocationSeed'] : null;
5152
$this->configurations = isset($split['configurations']) && count($split['configurations']) > 0 ?
5253
$split['configurations'] : null;
54+
$this->sets = isset($split['sets']) ? $split['sets'] : array();
5355

5456
SplitApp::logger()->info("Constructing Feature Flag: ".$this->name);
5557

@@ -167,4 +169,12 @@ public function getConfigurations()
167169
{
168170
return $this->configurations;
169171
}
172+
173+
/**
174+
* @return array|null
175+
*/
176+
public function getSets()
177+
{
178+
return $this->sets;
179+
}
170180
}

src/SplitIO/Metrics.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55

66
class Metrics
77
{
8-
const MNAME_SDK_GET_TREATMENT = 'sdk.getTreatment';
9-
const MNAME_SDK_GET_TREATMENT_WITH_CONFIG = 'sdk.getTreatmentWithConfig';
10-
const MNAME_SDK_GET_TREATMENTS = 'sdk.getTreatments';
11-
const MNAME_SDK_GET_TREATMENTS_WITH_CONFIG = 'sdk.getTreatmentsWithConfig';
12-
138
public static function startMeasuringLatency()
149
{
1510
return Latency::startMeasuringLatency();

0 commit comments

Comments
 (0)