Skip to content

Commit e6c53e9

Browse files
committed
fix(EventSourceClient) : remove the need calling opPatch when incremental cache is off
- remove preconditions check if no cache - update javadoc and demo
1 parent 46ba57a commit e6c53e9

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/main/java/io/streamdata/demo/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public static void main(String... args) throws URISyntaxException, InterruptedEx
4545
EventSourceClient eventSource = StreamdataClient.createClient(apiURL, appKey)
4646
.incrementalCache(false)
4747
.onSnapshot(data -> logger.info("INITIAL SNAPSHOT {}", data))
48-
.onPatch(System.out::println) // useless
4948
.onOpen(() -> logger.info("And we are... live!"))
5049
.open();
5150

src/main/java/io/streamdata/sdk/EventSourceClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public interface EventSourceClient {
1212
String SD_PROXY_URL = "https://streamdata.motwin.net/";
1313

1414

15-
1615
/**
1716
* Add a header to the polling request (those header will be passed to the request when SD.io will poll the API)
1817
*
@@ -88,7 +87,8 @@ public interface EventSourceClient {
8887

8988

9089
/**
91-
* Opens the connections with streamdata proxy that will poll data for you. {@link #onSnapshot(Consumer)} and {@link #onPatch(Consumer)} must have called before.
90+
* Opens the connections with streamdata proxy that will poll data for you.
91+
* {@link #onSnapshot(Consumer)} must have called before and {@link #onPatch(Consumer)} is incremental cache is on (default is yes unless you call {@link #incrementalCache(boolean)} with false.
9292
*
9393
* @return a future to get hints on the thread status
9494
*/

src/main/java/io/streamdata/sdk/impl/EventSourceClientImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ public JsonNode getCurrentSnapshot() {
145145
public EventSourceClient open() {
146146

147147
checkNotNull(this.onDataCallback, "You must call onSnapshot() with a non-null callback before calling open()");
148-
checkNotNull(this.onPatchCallback, "You must call onPatch() with a non-null callback before calling open()");
148+
if (incrementalCache) {
149+
checkNotNull(this.onPatchCallback, "You must call onPatch() with a non-null callback before calling open()");
150+
}
149151
checkArgument(this.eventSource == null, "You cannot call open() on an already opened event source");
150152

151153
try {

0 commit comments

Comments
 (0)