Skip to content

Commit

Permalink
wip: nooope had to remove more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre committed Jan 22, 2025
1 parent 459d6f7 commit a8b8594
Show file tree
Hide file tree
Showing 27 changed files with 161 additions and 479 deletions.
6 changes: 4 additions & 2 deletions src/main/java/io/getunleash/DefaultUnleash.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.getunleash;

import static io.getunleash.Variant.DISABLED_VARIANT;

import io.getunleash.event.EventDispatcher;
import io.getunleash.event.IsEnabledImpressionEvent;
import io.getunleash.event.ToggleEvaluated;
Expand All @@ -10,6 +8,10 @@
import io.getunleash.repository.FeatureRepository;
import io.getunleash.strategy.*;
import io.getunleash.util.UnleashConfig;
import io.getunleash.variant.Variant;

import static io.getunleash.variant.Variant.DISABLED_VARIANT;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.LongAdder;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/getunleash/EngineProxyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import io.getunleash.repository.YggdrasilAdapters;
import io.getunleash.strategy.Strategy;
import io.getunleash.util.UnleashConfig;
import io.getunleash.variant.Variant;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/getunleash/EvaluatedToggle.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.getunleash;

import io.getunleash.lang.Nullable;
import io.getunleash.variant.Variant;

public class EvaluatedToggle {
private final boolean enabled;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/getunleash/FakeUnleash.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.getunleash;

import io.getunleash.lang.Nullable;
import io.getunleash.variant.Variant;

import java.util.*;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
Expand Down
51 changes: 0 additions & 51 deletions src/main/java/io/getunleash/FeatureDependency.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/io/getunleash/FeatureEvaluationResult.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/io/getunleash/Unleash.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.function.BiPredicate;

import io.getunleash.variant.Variant;

public interface Unleash {
default boolean isEnabled(String toggleName) {
return isEnabled(toggleName, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.getunleash.repository;
package io.getunleash.event;

import io.getunleash.event.UnleashEvent;
import io.getunleash.event.UnleashSubscriber;
import java.util.Optional;

public final class ClientFeaturesResponse implements UnleashEvent {
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/io/getunleash/event/UnleashSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.getunleash.UnleashException;
import io.getunleash.metric.ClientMetrics;
import io.getunleash.metric.ClientRegistration;
import io.getunleash.repository.ClientFeaturesResponse;

import org.slf4j.LoggerFactory;

public interface UnleashSubscriber {
Expand All @@ -25,12 +25,6 @@ default void clientMetrics(ClientMetrics clientMetrics) {}

default void clientRegistered(ClientRegistration clientRegistration) {}

default void togglesBackedUp(String toggleCollection) {}

default void toggleBackupRestored(String toggleCollection) {}

default void togglesBootstrapped(String toggleCollection) {}

default void featuresBootstrapped(String featureCollection) {}

default void featuresBackedUp(String featureCollection) {}
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/main/java/io/getunleash/repository/FeatureFetcher.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.getunleash.repository;

import io.getunleash.UnleashException;
import io.getunleash.event.ClientFeaturesResponse;

public interface FeatureFetcher {
ClientFeaturesResponse fetchFeatures() throws UnleashException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import io.getunleash.FeatureDefinition;
import io.getunleash.UnleashContext;
import io.getunleash.Variant;
import io.getunleash.variant.Variant;

import java.util.stream.Stream;

public interface FeatureRepository {
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/io/getunleash/repository/FeatureRepositoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
import io.getunleash.FeatureDefinition;
import io.getunleash.UnleashContext;
import io.getunleash.UnleashException;
import io.getunleash.Variant;
import io.getunleash.engine.UnleashEngine;
import io.getunleash.engine.YggdrasilError;
import io.getunleash.engine.YggdrasilInvalidInputException;
import io.getunleash.event.ClientFeaturesResponse;
import io.getunleash.event.EventDispatcher;
import io.getunleash.event.UnleashReady;
import io.getunleash.util.Throttler;
import io.getunleash.util.UnleashConfig;
import io.getunleash.util.UnleashScheduledExecutor;
import io.getunleash.variant.Variant;

import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Stream;
Expand All @@ -22,7 +24,7 @@ public class FeatureRepositoryImpl implements FeatureRepository {
private static final Logger LOGGER = LoggerFactory.getLogger(FeatureRepositoryImpl.class);
private final UnleashConfig unleashConfig;
private final BackupHandler featureBackupHandler;
private final FeatureBootstrapHandler featureBootstrapHandler;
private final ToggleBootstrapProvider bootstrapper;
private final FeatureFetcher featureFetcher;
private final EventDispatcher eventDispatcher;
private final UnleashEngine engine;
Expand Down Expand Up @@ -52,15 +54,15 @@ public FeatureRepositoryImpl(
featureBackupHandler,
engine,
fetcher,
new FeatureBootstrapHandler(unleashConfig));
new ToggleBootstrapFileProvider());
}

public FeatureRepositoryImpl(
UnleashConfig unleashConfig,
BackupHandler featureBackupHandler,
UnleashEngine engine,
FeatureFetcher fetcher,
FeatureBootstrapHandler bootstrapHandler) {
ToggleBootstrapProvider bootstrapHandler) {
this(
unleashConfig,
featureBackupHandler,
Expand All @@ -75,27 +77,26 @@ public FeatureRepositoryImpl(
BackupHandler featureBackupHandler,
UnleashEngine engine,
FeatureFetcher fetcher,
FeatureBootstrapHandler bootstrapHandler,
ToggleBootstrapProvider bootstrapHandler,
EventDispatcher eventDispatcher) {
this.unleashConfig = unleashConfig;
this.featureBackupHandler = featureBackupHandler;
this.engine = engine;
this.featureFetcher = fetcher;
this.featureBootstrapHandler = bootstrapHandler;
this.bootstrapper = bootstrapHandler;
this.eventDispatcher = eventDispatcher;
this.throttler =
new Throttler(
(int) unleashConfig.getFetchTogglesInterval(),
300,
unleashConfig.getUnleashURLs().getFetchTogglesURL());
this.throttler = new Throttler(
(int) unleashConfig.getFetchTogglesInterval(),
300,
unleashConfig.getUnleashURLs().getFetchTogglesURL());
this.initCollections(unleashConfig.getScheduledExecutor());
}

@SuppressWarnings("FutureReturnValueIgnored")
private void initCollections(UnleashScheduledExecutor executor) {
Optional<String> features = this.featureBackupHandler.read();
if (!features.isPresent()) {
features = this.featureBootstrapHandler.read();
features = this.bootstrapper.read();
}
if (features.isPresent()) {
try {
Expand All @@ -110,9 +111,9 @@ private void initCollections(UnleashScheduledExecutor executor) {
updateFeatures(this.unleashConfig.getStartupExceptionHandler()).run();
} else {
updateFeatures(
e -> {
throw e;
})
e -> {
throw e;
})
.run();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.getunleash.repository;

import io.getunleash.UnleashException;
import io.getunleash.event.ClientFeaturesResponse;
import io.getunleash.util.UnleashConfig;
import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.JsonSyntaxException;
import io.getunleash.UnleashException;
import io.getunleash.event.ClientFeaturesResponse;
import io.getunleash.util.OkHttpClientConfigurer;
import io.getunleash.util.UnleashConfig;
import java.io.File;
Expand Down
Loading

0 comments on commit a8b8594

Please sign in to comment.