Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>io.getunleash</groupId>
<artifactId>yggdrasil-engine</artifactId>
<version>0.4.5</version>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import io.getunleash.UnleashContext;
import java.util.List;

/** @deprecated MetricFlagContext will be removed in a future release. */
/**
* @deprecated MetricFlagContext will be removed in a future release.
*/
@Deprecated(since = "12.1.1", forRemoval = true)
public class MetricFlagContext {
private final List<String> flagNames;
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/io/getunleash/impactmetrics/MetricsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ public interface MetricsAPI {

public void incrementCounter(String name, long value);

/** @deprecated MetricFlagContext will be removed in a future release. */
/**
* @deprecated MetricFlagContext will be removed in a future release.
*/
@Deprecated(since = "12.1.1", forRemoval = true)
public void incrementCounter(
String name, @Nullable Long value, @Nullable MetricFlagContext flagContext);

public void updateGauge(String name, double value);

/** @deprecated MetricFlagContext will be removed in a future release. */
/**
* @deprecated MetricFlagContext will be removed in a future release.
*/
@Deprecated(since = "12.1.1", forRemoval = true)
public void updateGauge(String name, double value, @Nullable MetricFlagContext flagContext);

Expand All @@ -36,7 +40,9 @@ public void incrementCounter(

public void observeHistogram(String name, double value);

/** @deprecated MetricFlagContext will be removed in a future release. */
/**
* @deprecated MetricFlagContext will be removed in a future release.
*/
@Deprecated(since = "12.1.1", forRemoval = true)
public void observeHistogram(
String name, double value, @Nullable MetricFlagContext flagContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.getunleash.strategies.custom;

import io.getunleash.UnleashContext;
import io.getunleash.strategy.Strategy;
import java.util.Map;

public class ConstraintEvaluatorCustom implements Strategy {
@Override
public String getName() {
return "repeated";
}

@Override
public boolean isEnabled(Map<String, String> parameters, UnleashContext context) {
return context.getProperties().get("myFancy").equals(parameters.get("myFancy"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.getunleash.strategies.custom;

import static org.assertj.core.api.Assertions.assertThat;

import io.getunleash.DefaultUnleash;
import io.getunleash.UnleashContext;
import io.getunleash.util.ResourceReader;
import io.getunleash.util.UnleashConfig;
import java.util.Optional;
import org.junit.jupiter.api.Test;

public class RepeatedCustomStrategyTest {
private String loadMockFeatures(String path) {
return ResourceReader.readResourceAsString(path);
}

@Test
public void
repeated_custom_strategy_evaluates_to_true_if_any_custom_strategy_evaluates_to_true() {
UnleashConfig config =
UnleashConfig.builder()
.unleashAPI("http://test:4242")
.appName("multiple_connection")
.instanceId("repeated_custom_strategy")
.toggleBootstrapProvider(
() ->
Optional.of(
loadMockFeatures("repeated_custom_strategy.json")))
.build();
var myUnleash = new DefaultUnleash(config, new ConstraintEvaluatorCustom());
UnleashContext context = UnleashContext.builder().addProperty("myFancy", "one").build();
assertThat(myUnleash.isEnabled("repeated.custom", context)).isTrue();
}
}
24 changes: 24 additions & 0 deletions src/test/resources/repeated_custom_strategy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 2,
"features": [
{
"name": "repeated.custom",
"enabled": true,
"strategies": [
{
"name": "repeated",
"parameters": {
"myFancy": "one"
}

},
{
"name": "repeated",
"parameters": {
"myFancy": "two"
}
}
]
}
]
}
Loading