Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDKS-7888] Impression Listener SYNC/ASYNC by config #468

Merged
merged 16 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/update-license-year.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -24,7 +24,7 @@ jobs:
run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"

- name: Update LICENSE
uses: jacobtomlinson/gha-find-replace@v2
uses: jacobtomlinson/gha-find-replace@v3
with:
find: ${{ env.PREVIOUS }}
replace: ${{ env.CURRENT }}
Expand All @@ -38,7 +38,7 @@ jobs:
git commit -m "Updated License Year" -a

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Update License Year
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
4.11.0 (Jan XX, 2024)
- Added impressionsListener method in the IntegrationConfig builder to set Sync or Async Listener execution.

4.10.2 (Dec 1, 2023)
- Added getTreatmentsByFlagSets without attributes.
- Fixed some issues for flag sets: Not logging a warning when using flag sets that don't contain cached feature flags.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2023 Split Software, Inc.
Copyright © 2024 Split Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ public Builder() {
}

public Builder impressionsListener(ImpressionListener listener, int queueSize) {
return impressionsListener(listener, queueSize, Execution.ASYNC);
}

public Builder impressionsListener(ImpressionListener listener, int queueSize, Execution executionType) {
if (queueSize <= 0) {
throw new IllegalArgumentException("An ImpressionListener was provided, but its capacity was non-positive: " + queueSize);
}
_listeners.add(new ImpressionListenerWithMeta(listener, Execution.ASYNC, queueSize));
_listeners.add(new ImpressionListenerWithMeta(listener, executionType, queueSize));
return this;
}

Expand Down
21 changes: 21 additions & 0 deletions client/src/test/java/io/split/client/SplitClientConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.split.integrations.IntegrationsConfig;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;

import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -214,4 +215,24 @@ public void threadFactoryNotNull() {
SplitClientConfig config = SplitClientConfig.builder().threadFactory(new ThreadFactoryBuilder().build()).build();
Assert.assertNotNull(config.getThreadFactory());
}

@Test
public void IntegrationConfigSyncNotNull() {
SplitClientConfig config = SplitClientConfig.builder().integrations(IntegrationsConfig.builder()
.impressionsListener(Mockito.mock(ImpressionListener.class), 500, IntegrationsConfig.Execution.SYNC)
.build()).build();
Assert.assertNotNull(config.integrationsConfig());
Assert.assertEquals(1, config.integrationsConfig().getImpressionsListeners(IntegrationsConfig.Execution.SYNC).size());
Assert.assertEquals(0, config.integrationsConfig().getImpressionsListeners(IntegrationsConfig.Execution.ASYNC).size());
}

@Test
public void IntegrationConfigAsyncNotNull() {
SplitClientConfig config = SplitClientConfig.builder().integrations(IntegrationsConfig.builder()
.impressionsListener(Mockito.mock(ImpressionListener.class), 500, IntegrationsConfig.Execution.ASYNC)
.build()).build();
Assert.assertNotNull(config.integrationsConfig());
Assert.assertEquals(0, config.integrationsConfig().getImpressionsListeners(IntegrationsConfig.Execution.SYNC).size());
Assert.assertEquals(1, config.integrationsConfig().getImpressionsListeners(IntegrationsConfig.Execution.ASYNC).size());
}
}