Skip to content

Commit 6d42628

Browse files
meghans-cashtgregory-block
authored andcommitted
Add flush_interval to the LaunchDarklyConfig, default to the
default flush interval to allow configuring how often events are sent GitOrigin-RevId: 5e36390bc9fe80da834a7b8baf036591e85536fa
1 parent 99f639a commit 6d42628

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

misk-launchdarkly/api/misk-launchdarkly.api

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ public final class misk/feature/launchdarkly/LaunchDarklyConfig : wisp/config/Co
33
public fun <init> (Ljava/lang/String;Ljava/lang/String;Z)V
44
public fun <init> (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;)V
55
public fun <init> (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;I)V
6-
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
6+
public fun <init> (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;ILjava/time/Duration;)V
7+
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;ILjava/time/Duration;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
78
public final fun component1 ()Ljava/lang/String;
89
public final fun component2 ()Ljava/lang/String;
910
public final fun component3 ()Z
1011
public final fun component4 ()Lmisk/client/HttpClientSSLConfig;
1112
public final fun component5 ()I
12-
public final fun copy (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;I)Lmisk/feature/launchdarkly/LaunchDarklyConfig;
13-
public static synthetic fun copy$default (Lmisk/feature/launchdarkly/LaunchDarklyConfig;Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;IILjava/lang/Object;)Lmisk/feature/launchdarkly/LaunchDarklyConfig;
13+
public final fun component6 ()Ljava/time/Duration;
14+
public final fun copy (Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;ILjava/time/Duration;)Lmisk/feature/launchdarkly/LaunchDarklyConfig;
15+
public static synthetic fun copy$default (Lmisk/feature/launchdarkly/LaunchDarklyConfig;Ljava/lang/String;Ljava/lang/String;ZLmisk/client/HttpClientSSLConfig;ILjava/time/Duration;ILjava/lang/Object;)Lmisk/feature/launchdarkly/LaunchDarklyConfig;
1416
public fun equals (Ljava/lang/Object;)Z
1517
public final fun getBase_uri ()Ljava/lang/String;
1618
public final fun getEvent_capacity ()I
19+
public final fun getFlush_interval ()Ljava/time/Duration;
1720
public final fun getSdk_key ()Ljava/lang/String;
1821
public final fun getSsl ()Lmisk/client/HttpClientSSLConfig;
1922
public final fun getUse_relay_proxy ()Z

misk-launchdarkly/src/main/kotlin/misk/feature/launchdarkly/LaunchDarklyFeatureFlagsModule.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.launchdarkly.sdk.server.Components
66
import com.launchdarkly.sdk.server.LDClient
77
import com.launchdarkly.sdk.server.LDConfig
88
import com.launchdarkly.sdk.server.integrations.EventProcessorBuilder.DEFAULT_CAPACITY
9+
import com.launchdarkly.sdk.server.integrations.EventProcessorBuilder.DEFAULT_FLUSH_INTERVAL
910
import com.launchdarkly.sdk.server.interfaces.LDClientInterface
1011
import com.squareup.moshi.Moshi
1112
import io.micrometer.core.instrument.MeterRegistry
@@ -66,7 +67,11 @@ class LaunchDarklyModule @JvmOverloads constructor(
6667
// Set wait to 0 to not block here. Block in service initialization instead.
6768
.startWait(Duration.ofMillis(0))
6869
.dataSource(Components.streamingDataSource())
69-
.events(Components.sendEvents().capacity(config.event_capacity))
70+
.events(
71+
Components.sendEvents()
72+
.capacity(config.event_capacity)
73+
.flushInterval(config.flush_interval)
74+
)
7075

7176
if (config.use_relay_proxy) {
7277
ldConfig.serviceEndpoints(
@@ -97,4 +102,5 @@ data class LaunchDarklyConfig @JvmOverloads constructor(
97102
val use_relay_proxy: Boolean = true,
98103
val ssl: HttpClientSSLConfig? = null,
99104
val event_capacity: Int = DEFAULT_CAPACITY,
105+
val flush_interval: Duration = DEFAULT_FLUSH_INTERVAL,
100106
) : Config

wisp/wisp-launchdarkly/api/wisp-launchdarkly.api

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ public final class wisp/launchdarkly/LaunchDarklyConfig : wisp/config/Config {
2121
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;)V
2222
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;Z)V
2323
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZI)V
24-
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZIILkotlin/jvm/internal/DefaultConstructorMarker;)V
24+
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZILjava/time/Duration;)V
25+
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZILjava/time/Duration;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
2526
public final fun component1 ()Ljava/lang/String;
2627
public final fun component2 ()Ljava/lang/String;
2728
public final fun component3 ()Lwisp/client/HttpClientSSLConfig;
2829
public final fun component4 ()Z
2930
public final fun component5 ()I
30-
public final fun copy (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZI)Lwisp/launchdarkly/LaunchDarklyConfig;
31-
public static synthetic fun copy$default (Lwisp/launchdarkly/LaunchDarklyConfig;Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZIILjava/lang/Object;)Lwisp/launchdarkly/LaunchDarklyConfig;
31+
public final fun component6 ()Ljava/time/Duration;
32+
public final fun copy (Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZILjava/time/Duration;)Lwisp/launchdarkly/LaunchDarklyConfig;
33+
public static synthetic fun copy$default (Lwisp/launchdarkly/LaunchDarklyConfig;Ljava/lang/String;Ljava/lang/String;Lwisp/client/HttpClientSSLConfig;ZILjava/time/Duration;ILjava/lang/Object;)Lwisp/launchdarkly/LaunchDarklyConfig;
3234
public fun equals (Ljava/lang/Object;)Z
3335
public final fun getBase_uri ()Ljava/lang/String;
3436
public final fun getEvent_capacity ()I
37+
public final fun getFlush_interval ()Ljava/time/Duration;
3538
public final fun getOffline ()Z
3639
public final fun getSdk_key ()Ljava/lang/String;
3740
public final fun getSsl ()Lwisp/client/HttpClientSSLConfig;

wisp/wisp-launchdarkly/src/main/kotlin/wisp/launchdarkly/LaunchDarklyClient.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ object LaunchDarklyClient {
3333
.streaming(baseUri)
3434
.events(baseUri)
3535
)
36-
.events(Components.sendEvents().capacity(config.event_capacity))
36+
.events(
37+
Components.sendEvents()
38+
.capacity(config.event_capacity)
39+
.flushInterval(config.flush_interval)
40+
)
3741

3842
config.ssl?.let {
3943
val trustStore = sslLoader.loadTrustStore(config.ssl.trust_store)!!
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package wisp.launchdarkly
22

33
import com.launchdarkly.sdk.server.integrations.EventProcessorBuilder.DEFAULT_CAPACITY
4+
import com.launchdarkly.sdk.server.integrations.EventProcessorBuilder.DEFAULT_FLUSH_INTERVAL
45
import wisp.client.HttpClientSSLConfig
56
import wisp.config.Config
7+
import java.time.Duration
68

79
data class LaunchDarklyConfig @JvmOverloads constructor(
810
val sdk_key: String,
911
val base_uri: String,
1012
val ssl: HttpClientSSLConfig? = null,
1113
val offline: Boolean = false,
12-
val event_capacity: Int = DEFAULT_CAPACITY
14+
val event_capacity: Int = DEFAULT_CAPACITY,
15+
val flush_interval: Duration = DEFAULT_FLUSH_INTERVAL
1316
) : Config

0 commit comments

Comments
 (0)