Skip to content

Commit 46ba57a

Browse files
committed
refactor(EventSourceClient) : change some return types
- Remove unused Future as return type - add EventSourceClient as return type of open() - update demo code
1 parent 845b45e commit 46ba57a

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static void main(String... args) throws URISyntaxException, InterruptedEx
4242
* */
4343
{
4444

45-
EventSourceClient eventSource = StreamdataClient.createClient(apiURL, appKey);
46-
eventSource.incrementalCache(false)
45+
EventSourceClient eventSource = StreamdataClient.createClient(apiURL, appKey)
46+
.incrementalCache(false)
4747
.onSnapshot(data -> logger.info("INITIAL SNAPSHOT {}", data))
4848
.onPatch(System.out::println) // useless
4949
.onOpen(() -> logger.info("And we are... live!"))

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.fasterxml.jackson.databind.JsonNode;
44

5-
import java.util.concurrent.Future;
65
import java.util.function.Consumer;
76

87
/**
@@ -93,7 +92,7 @@ public interface EventSourceClient {
9392
*
9493
* @return a future to get hints on the thread status
9594
*/
96-
Future<?> open();
95+
EventSourceClient open();
9796

9897
/**
9998
* Closes the event source gracefully

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.net.URI;
2222
import java.net.URISyntaxException;
2323
import java.net.URLEncoder;
24-
import java.util.concurrent.Future;
2524
import java.util.concurrent.atomic.AtomicReference;
2625
import java.util.function.Consumer;
2726

@@ -143,7 +142,7 @@ public JsonNode getCurrentSnapshot() {
143142

144143

145144
@Override
146-
public Future<?> open() {
145+
public EventSourceClient open() {
147146

148147
checkNotNull(this.onDataCallback, "You must call onSnapshot() with a non-null callback before calling open()");
149148
checkNotNull(this.onPatchCallback, "You must call onPatch() with a non-null callback before calling open()");
@@ -234,7 +233,7 @@ public void onEvent(InboundEvent inboundEvent) {
234233
System.exit(1);
235234
}
236235

237-
return null;
236+
return this;
238237

239238

240239
}

0 commit comments

Comments
 (0)