You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An asynchronous SDK client is also available that returns a [`CompletableFuture<T>`][comp-fut]. See [Asynchronous Support](#asynchronous-support) for more details on async benefits and reactive library integration.
*[list](docs/sdks/connectioncustommappings/README.md#list) - List connection custom mappings
@@ -713,7 +776,6 @@ For certain operations, you can also use the `callAsStreamUnwrapped` method that
713
776
714
777
Here's an example depicting the different ways to use pagination:
715
778
716
-
717
779
```java
718
780
packagehello.world;
719
781
@@ -750,8 +812,8 @@ public class Application {
750
812
.fields("id,updated_at")
751
813
.build();
752
814
753
-
var b = sdk.accounting().taxRates().list()
754
-
.request(req);
815
+
816
+
var b = sdk.accounting().taxRates().list();
755
817
756
818
// Iterate through all pages using a traditional for-each loop
757
819
// Each iteration returns a complete page response
@@ -772,6 +834,60 @@ public class Application {
772
834
}
773
835
}
774
836
```
837
+
#### Asynchronous Pagination
838
+
An asynchronous SDK client is also available for pagination that returns a [`Flow.Publisher<T>`][flow-pub]. For async pagination, you can use `callAsPublisher()` to get pages as a publisher, or `callAsPublisherUnwrapped()` to get individual items directly. See [Asynchronous Support](#asynchronous-support) for more details on async benefits and reactive library integration.
@@ -1055,14 +1171,77 @@ public class Application {
1055
1171
.serverURL("https://upload.apideck.com")
1056
1172
.call();
1057
1173
1058
-
if (res.createAttachmentResponse().isPresent()) {
1059
-
// handle response
1060
-
}
1061
1174
}
1062
1175
}
1063
1176
```
1064
1177
<!-- End Server Selection [server] -->
1065
1178
1179
+
<!-- Start Asynchronous Support [async-support] -->
1180
+
## Asynchronous Support
1181
+
1182
+
The SDK provides comprehensive asynchronous support using Java's [`CompletableFuture<T>`][comp-fut] and [Reactive Streams `Publisher<T>`][reactive-streams] APIs. This design makes no assumptions about your choice of reactive toolkit, allowing seamless integration with any reactive library.
1183
+
1184
+
<details>
1185
+
<summary>Why Use Async?</summary>
1186
+
1187
+
Asynchronous operations provide several key benefits:
1188
+
1189
+
-**Non-blocking I/O**: Your threads stay free for other work while operations are in flight
1190
+
-**Better resource utilization**: Handle more concurrent operations with fewer threads
1191
+
-**Improved scalability**: Build highly responsive applications that can handle thousands of concurrent requests
1192
+
-**Reactive integration**: Works seamlessly with reactive streams and backpressure handling
1193
+
1194
+
</details>
1195
+
1196
+
<details>
1197
+
<summary>Reactive Library Integration</summary>
1198
+
1199
+
The SDK returns [Reactive Streams `Publisher<T>`][reactive-streams] instances for operations dealing with streams involving multiple I/O interactions. We use Reactive Streams instead of JDK Flow API to provide broader compatibility with the reactive ecosystem, as most reactive libraries natively support Reactive Streams.
1200
+
1201
+
**Why Reactive Streams over JDK Flow?**
1202
+
-**Broader ecosystem compatibility**: Most reactive libraries (Project Reactor, RxJava, Akka Streams, etc.) natively support Reactive Streams
1203
+
-**Industry standard**: Reactive Streams is the de facto standard for reactive programming in Java
1204
+
-**Better interoperability**: Seamless integration without additional adapters for most use cases
1205
+
1206
+
**Integration with Popular Libraries:**
1207
+
-**Project Reactor**: Use `Flux.from(publisher)` to convert to Reactor types
1208
+
-**RxJava**: Use `Flowable.fromPublisher(publisher)` for RxJava integration
1209
+
-**Akka Streams**: Use `Source.fromPublisher(publisher)` for Akka Streams integration
1210
+
-**Vert.x**: Use `ReadStream.fromPublisher(vertx, publisher)` for Vert.x reactive streams
1211
+
-**Mutiny**: Use `Multi.createFrom().publisher(publisher)` for Quarkus Mutiny integration
1212
+
1213
+
**For JDK Flow API Integration:**
1214
+
If you need JDK Flow API compatibility (e.g., for Quarkus/Mutiny 2), you can use adapters:
1215
+
```java
1216
+
// Convert Reactive Streams Publisher to Flow Publisher
0 commit comments