prevent the flags log from spamming
This commit is contained in:
parent
b458e24f29
commit
993dfafed9
@ -2,6 +2,8 @@ package cc.pulseapp.api.model;
|
|||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A feature flag.
|
* A feature flag.
|
||||||
*
|
*
|
||||||
@ -30,6 +32,8 @@ public enum Feature {
|
|||||||
*/
|
*/
|
||||||
@Setter private Object value;
|
@Setter private Object value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a feature by its id.
|
* Get a feature by its id.
|
||||||
*
|
*
|
||||||
@ -44,4 +48,18 @@ public enum Feature {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the combined hash
|
||||||
|
* code of all features.
|
||||||
|
*
|
||||||
|
* @return the combined hash code
|
||||||
|
*/
|
||||||
|
public static int hash() {
|
||||||
|
int hash = 0;
|
||||||
|
for (Feature feature : VALUES) {
|
||||||
|
hash+= Objects.hash(feature.isEnabled(), feature.getValue());
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
}
|
}
|
@ -45,6 +45,7 @@ public final class FlagsService {
|
|||||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||||
@Override @SneakyThrows
|
@Override @SneakyThrows
|
||||||
public void run() {
|
public void run() {
|
||||||
|
int oldFlags = Feature.hash();
|
||||||
for (BaseFlag flag : client.getEnvironmentFlags().getAllFlags()) {
|
for (BaseFlag flag : client.getEnvironmentFlags().getAllFlags()) {
|
||||||
Feature feature = Feature.getById(flag.getFeatureName());
|
Feature feature = Feature.getById(flag.getFeatureName());
|
||||||
if (feature == null) {
|
if (feature == null) {
|
||||||
@ -54,7 +55,9 @@ public final class FlagsService {
|
|||||||
feature.setEnabled(flag.getEnabled());
|
feature.setEnabled(flag.getEnabled());
|
||||||
feature.setValue(value instanceof String stringedValue && (stringedValue.isBlank()) ? null : value);
|
feature.setValue(value instanceof String stringedValue && (stringedValue.isBlank()) ? null : value);
|
||||||
}
|
}
|
||||||
log.info("Fetched new flags (:");
|
if (oldFlags != Feature.hash()) {
|
||||||
|
log.info("Fetched new flags (:");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 0L, FETCH_INTERVAL);
|
}, 0L, FETCH_INTERVAL);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user