Skip to content

Commit

Permalink
Change sseDisconnectionDelay type (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
gthea authored Sep 10, 2024
1 parent b5b7bd6 commit e6795bb
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'kotlin-android'
apply from: 'spec.gradle'

ext {
splitVersion = '4.2.0'
splitVersion = '4.2.1-rc1'
}

android {
Expand Down
10 changes: 5 additions & 5 deletions src/androidTest/java/helper/IntegrationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,22 @@ public static SplitClientConfig lowRefreshRateConfig() {
}

public static SplitClientConfig lowRefreshRateConfig(boolean streamingEnabled) {
return lowRefreshRateConfig(streamingEnabled, false, true, 60L, 2L);
return lowRefreshRateConfig(streamingEnabled, false, true, 60L, 2);
}

public static SplitClientConfig lowRefreshRateConfig(boolean streamingEnabled, boolean telemetryEnabled) {
return lowRefreshRateConfig(streamingEnabled, telemetryEnabled, true, 60L, 2L);
return lowRefreshRateConfig(streamingEnabled, telemetryEnabled, true, 60L, 2);
}

public static SplitClientConfig syncDisabledConfig() {
return lowRefreshRateConfig(true, false, false, 60L, 2L);
return lowRefreshRateConfig(true, false, false, 60L, 2);
}

public static SplitClientConfig customSseConnectionDelayConfig(boolean streamingEnabled, long delay, long disconnectionDelay) {
public static SplitClientConfig customSseConnectionDelayConfig(boolean streamingEnabled, long delay, int disconnectionDelay) {
return lowRefreshRateConfig(streamingEnabled, false, true, delay, disconnectionDelay);
}

public static SplitClientConfig lowRefreshRateConfig(boolean streamingEnabled, boolean telemetryEnabled, boolean syncEnabled, long delay, long sseDisconnectionDelay) {
public static SplitClientConfig lowRefreshRateConfig(boolean streamingEnabled, boolean telemetryEnabled, boolean syncEnabled, long delay, int sseDisconnectionDelay) {
TestableSplitConfigBuilder builder = new TestableSplitConfigBuilder()
.ready(30000)
.featuresRefreshRate(3)
Expand Down
4 changes: 2 additions & 2 deletions src/androidTest/java/helper/TestableSplitConfigBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class TestableSplitConfigBuilder {
private UserConsent mUserConsent = UserConsent.GRANTED;
private boolean mEncryptionEnabled;
private long mDefaultSSEConnectionDelayInSecs = ServiceConstants.DEFAULT_SSE_CONNECTION_DELAY_SECS;
private long mSSEDisconnectionDelayInSecs = 60L;
private int mSSEDisconnectionDelayInSecs = 60;
private long mObserverCacheExpirationPeriod = ServiceConstants.DEFAULT_OBSERVER_CACHE_EXPIRATION_PERIOD_MS;
private String mPrefix = "";
private CertificatePinningConfiguration mCertificatePinningConfiguration;
Expand Down Expand Up @@ -249,7 +249,7 @@ public TestableSplitConfigBuilder defaultSSEConnectionDelayInSecs(long seconds)
return this;
}

public TestableSplitConfigBuilder sseDisconnectionDelayInSecs(long seconds) {
public TestableSplitConfigBuilder sseDisconnectionDelayInSecs(int seconds) {
this.mSSEDisconnectionDelayInSecs = seconds;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private void testSplitNotification(String notificationMessage) throws IOExceptio
private Pair<SplitClient, SplitEventTaskHelper> getClient(CountDownLatch latch, String sseResponse) throws IOException, InterruptedException {
HttpClientMock httpClientMock = new HttpClientMock(createStreamingResponseDispatcher(sseResponse));

SplitClientConfig config = IntegrationHelper.customSseConnectionDelayConfig(true, 0, 5L);
SplitClientConfig config = IntegrationHelper.customSseConnectionDelayConfig(true, 0, 5);

SplitFactory splitFactory = IntegrationHelper.buildFactory(
IntegrationHelper.dummyApiKey(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void changeInStreamingDelayAffectsSyncBehaviour() throws IOException, Int
false,
IntegrationHelper.streamingEnabledToken(6),
1L,
1L,
1,
null);
SplitClient client = pair.first;
SplitEventTaskHelper readyTask = pair.second;
Expand Down Expand Up @@ -233,10 +233,10 @@ public void splitsAreNotFetchedOnResumeWhenSingleSyncIsEnabled() throws Interrup
}

private Pair<SplitClient, SplitEventTaskHelper> getClient(CountDownLatch latch, boolean streamingEnabled, boolean singleSync, String sseResponse) throws IOException {
return getClient(latch, streamingEnabled, singleSync, sseResponse, 2L, 2L, null);
return getClient(latch, streamingEnabled, singleSync, sseResponse, 2L, 2, null);
}

private Pair<SplitClient, SplitEventTaskHelper> getClient(CountDownLatch latch, boolean streamingEnabled, boolean singleSync, String sseResponse, long defaultConnectionDelay, long disconnectionDelay, TestingConfig testingConfig) throws IOException {
private Pair<SplitClient, SplitEventTaskHelper> getClient(CountDownLatch latch, boolean streamingEnabled, boolean singleSync, String sseResponse, long defaultConnectionDelay, int disconnectionDelay, TestingConfig testingConfig) throws IOException {
HttpClientMock httpClientMock = new HttpClientMock(createStreamingResponseDispatcher(sseResponse));

SplitClientConfig config = (singleSync) ? IntegrationHelper.syncDisabledConfig() : IntegrationHelper.customSseConnectionDelayConfig(streamingEnabled, defaultConnectionDelay, disconnectionDelay);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/split/android/client/SplitClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class SplitClientConfig {
private boolean mEncryptionEnabled = false;
private final String mPrefix;
private final long mDefaultSSEConnectionDelayInSecs;
private final long mSSEDisconnectionDelayInSecs;
private final int mSSEDisconnectionDelayInSecs;

// To be set during startup
public static String splitSdkVersion;
Expand Down Expand Up @@ -182,7 +182,7 @@ private SplitClientConfig(String endpoint,
UserConsent userConsent,
boolean encryptionEnabled,
long defaultSSEConnectionDelayInSecs,
long sseDisconnectionDelayInSecs,
int sseDisconnectionDelayInSecs,
String prefix,
long observerCacheExpirationPeriod,
CertificatePinningConfiguration certificatePinningConfiguration,
Expand Down Expand Up @@ -469,7 +469,7 @@ public long defaultSSEConnectionDelay() {
return mDefaultSSEConnectionDelayInSecs;
}

public long sseDisconnectionDelay() {
public int sseDisconnectionDelay() {
return mSSEDisconnectionDelayInSecs;
}

Expand Down Expand Up @@ -553,7 +553,7 @@ public static final class Builder {

private final long mDefaultSSEConnectionDelayInSecs = ServiceConstants.DEFAULT_SSE_CONNECTION_DELAY_SECS;

private final long mSSEDisconnectionDelayInSecs = 60L;
private final int mSSEDisconnectionDelayInSecs = 60;

private final long mObserverCacheExpirationPeriod = OBSERVER_CACHE_EXPIRATION_PERIOD;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ PushNotificationManager getPushNotificationManager(SplitTaskExecutor splitTaskEx
SseClient sseClient,
TelemetryRuntimeProducer telemetryRuntimeProducer,
long defaultSseConnectionDelayInSecs,
long sseDisconnectionDelayInSecs) {
int sseDisconnectionDelayInSecs) {
return new PushNotificationManager(pushManagerEventBroadcaster,
sseAuthenticator,
sseClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.split.android.client.service.sseclient.sseclient;

import static io.split.android.client.utils.Utils.checkNotNull;
import static java.lang.Thread.sleep;
import static io.split.android.client.utils.Utils.checkNotNull;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import io.split.android.client.service.executor.ThreadFactoryBuilder;

import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand All @@ -19,6 +17,7 @@
import io.split.android.client.service.executor.SplitTask;
import io.split.android.client.service.executor.SplitTaskExecutionInfo;
import io.split.android.client.service.executor.SplitTaskType;
import io.split.android.client.service.executor.ThreadFactoryBuilder;
import io.split.android.client.service.sseclient.SseJwtToken;
import io.split.android.client.service.sseclient.feedbackchannel.DelayStatusEvent;
import io.split.android.client.service.sseclient.feedbackchannel.PushManagerEventBroadcaster;
Expand Down Expand Up @@ -54,13 +53,13 @@ public PushNotificationManager(@NonNull PushManagerEventBroadcaster pushManagerE
@NonNull SseRefreshTokenTimer refreshTokenTimer,
@NonNull TelemetryRuntimeProducer telemetryRuntimeProducer,
long defaultSSEConnectionDelayInSecs,
long sseDisconnectionDelayInSecs,
int sseDisconnectionDelayInSecs,
@Nullable ScheduledExecutorService executorService) {
this(pushManagerEventBroadcaster,
sseAuthenticator,
sseClient,
refreshTokenTimer,
new SseDisconnectionTimer(new SplitSingleThreadTaskExecutor(), Math.toIntExact(sseDisconnectionDelayInSecs)),
new SseDisconnectionTimer(new SplitSingleThreadTaskExecutor(), sseDisconnectionDelayInSecs),
telemetryRuntimeProducer,
defaultSSEConnectionDelayInSecs,
executorService);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.split.android.client.service.sseclient.sseclient;

import static com.google.gson.internal.$Gson$Preconditions.checkNotNull;
import static io.split.android.client.utils.Utils.checkNotNull;

import androidx.annotation.NonNull;

Expand Down

0 comments on commit e6795bb

Please sign in to comment.