Skip to content

Commit 082445c

Browse files
Merge pull request #7 from saasquatch/dev
Dev
2 parents b290ab1 + 45b08c5 commit 082445c

File tree

8 files changed

+52
-46
lines changed

8 files changed

+52
-46
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ Maven
101101
<dependency>
102102
<groupId>com.github.saasquatch</groupId>
103103
<artifactId>apache-client5-reactive</artifactId>
104-
<version>0.0.5</version>
104+
<version>0.0.6</version>
105105
</dependency>
106106
```
107107

108108
Gradle
109109

110110
```gradle
111-
implementation 'com.github.saasquatch:apache-client5-reactive:0.0.5'
111+
implementation 'com.github.saasquatch:apache-client5-reactive:0.0.6'
112112
```
113113

114114
## License

pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<groupId>com.saasquatch</groupId>
56
<artifactId>apache-client5-reactive</artifactId>
6-
<version>0.0.5-SNAPSHOT</version>
7+
<version>0.0.6-SNAPSHOT</version>
78
<packaging>jar</packaging>
89

910
<name>apache-client5-reactive</name>
@@ -19,7 +20,7 @@
1920

2021
<properties>
2122
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22-
<junit.version>5.8.1</junit.version>
23+
<junit.version>5.9.1</junit.version>
2324
</properties>
2425

2526
<dependencies>
@@ -38,17 +39,17 @@
3839
<dependency>
3940
<groupId>org.apache.httpcomponents.client5</groupId>
4041
<artifactId>httpclient5</artifactId>
41-
<version>5.1.2</version>
42+
<version>5.2.1</version>
4243
</dependency>
4344
<dependency>
4445
<groupId>org.apache.httpcomponents.core5</groupId>
4546
<artifactId>httpcore5-reactive</artifactId>
46-
<version>5.1.1</version>
47+
<version>5.2</version>
4748
</dependency>
4849
<dependency>
4950
<groupId>io.reactivex.rxjava3</groupId>
5051
<artifactId>rxjava</artifactId>
51-
<version>3.1.2</version>
52+
<version>3.1.5</version>
5253
</dependency>
5354
<dependency>
5455
<groupId>com.google.code.findbugs</groupId>
@@ -58,7 +59,7 @@
5859
<dependency>
5960
<groupId>org.slf4j</groupId>
6061
<artifactId>slf4j-simple</artifactId>
61-
<version>1.7.32</version>
62+
<version>2.0.5</version>
6263
<scope>test</scope>
6364
</dependency>
6465
</dependencies>

src/main/java/com/saasquatch/client5reactive/FutureCallbacks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.saasquatch.client5reactive;
22

3+
import io.reactivex.rxjava3.core.MaybeEmitter;
34
import java.util.concurrent.CancellationException;
45
import org.apache.hc.core5.concurrent.FutureCallback;
5-
import io.reactivex.rxjava3.core.MaybeEmitter;
66

77
/**
88
* Utilities for {@link FutureCallback}s. Not public.

src/main/java/com/saasquatch/client5reactive/HttpReactiveClient.java

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,44 @@
2323
/**
2424
* Thin wrapper around Apache {@link HttpAsyncClient} to expose
2525
* <a href="https://www.reactive-streams.org/">Reactive Streams</a> interfaces.<br>
26-
* The methods in this interface aim to mirror the ones in {@link HttpAsyncClient} and {@link
27-
* CloseableHttpAsyncClient}.
26+
* The methods in this interface aim to mirror the ones in {@link HttpAsyncClient} and
27+
* {@link CloseableHttpAsyncClient}.
2828
*
2929
* @author sli
3030
* @see HttpReactiveClients
3131
*/
3232
public interface HttpReactiveClient {
3333

3434
/**
35-
* Execute the given request. This method is equivalent to {@link HttpAsyncClient#execute(AsyncRequestProducer,
36-
* AsyncResponseConsumer, HandlerFactory, HttpContext, FutureCallback)}. If the {@link Future}
37-
* produced by the equivalent {@link HttpAsyncClient} method completes with {@code null}, then the
38-
* returning {@link Publisher} of this method will complete with no element.
35+
* Execute the given request. This method is equivalent to
36+
* {@link HttpAsyncClient#execute(AsyncRequestProducer, AsyncResponseConsumer, HandlerFactory,
37+
* HttpContext, FutureCallback)}. If the {@link Future} produced by the equivalent
38+
* {@link HttpAsyncClient} method completes with {@code null}, then the returning
39+
* {@link Publisher} of this method will complete with no element.
3940
*/
4041
<T> Publisher<T> execute(@Nonnull AsyncRequestProducer requestProducer,
4142
@Nonnull AsyncResponseConsumer<T> responseConsumer,
4243
@Nullable HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
4344
@Nullable HttpContext context);
4445

4546
/**
46-
* Convenience method for {@link #execute(AsyncRequestProducer, AsyncResponseConsumer,
47-
* HandlerFactory, HttpContext)}, equivalent to {@link CloseableHttpAsyncClient#execute(AsyncRequestProducer,
48-
* AsyncResponseConsumer, HttpContext, FutureCallback)}
47+
* Convenience method for
48+
* {@link #execute(AsyncRequestProducer, AsyncResponseConsumer, HandlerFactory, HttpContext)},
49+
* equivalent to
50+
* {@link CloseableHttpAsyncClient#execute(AsyncRequestProducer, AsyncResponseConsumer,
51+
* HttpContext, FutureCallback)}
4952
*/
5053
default <T> Publisher<T> execute(@Nonnull AsyncRequestProducer requestProducer,
5154
@Nonnull AsyncResponseConsumer<T> responseConsumer, @Nullable HttpContext context) {
5255
return execute(requestProducer, responseConsumer, null, context);
5356
}
5457

5558
/**
56-
* Convenience method for {@link #execute(AsyncRequestProducer, AsyncResponseConsumer,
57-
* HandlerFactory, HttpContext)}, equivalent to {@link CloseableHttpAsyncClient#execute(AsyncRequestProducer,
58-
* AsyncResponseConsumer, FutureCallback)}.
59+
* Convenience method for
60+
* {@link #execute(AsyncRequestProducer, AsyncResponseConsumer, HandlerFactory, HttpContext)},
61+
* equivalent to
62+
* {@link CloseableHttpAsyncClient#execute(AsyncRequestProducer, AsyncResponseConsumer,
63+
* FutureCallback)}.
5964
*/
6065
default <T> Publisher<T> execute(@Nonnull AsyncRequestProducer requestProducer,
6166
@Nonnull AsyncResponseConsumer<T> responseConsumer) {
@@ -64,62 +69,63 @@ default <T> Publisher<T> execute(@Nonnull AsyncRequestProducer requestProducer,
6469

6570
/**
6671
* Execute a simple in-memory request and get a simple in-memory response. This method is
67-
* equivalent to {@link CloseableHttpAsyncClient#execute(SimpleHttpRequest, HttpContext,
68-
* FutureCallback)}. The returning {@link Publisher} completes with exactly 1 element.
72+
* equivalent to
73+
* {@link CloseableHttpAsyncClient#execute(SimpleHttpRequest, HttpContext, FutureCallback)}. The
74+
* returning {@link Publisher} completes with exactly 1 element.
6975
*/
7076
default Publisher<SimpleHttpResponse> execute(@Nonnull SimpleHttpRequest request,
7177
@Nullable HttpContext context) {
7278
return execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), context);
7379
}
7480

7581
/**
76-
* Convenience method for {@link #execute(SimpleHttpRequest, HttpContext)}, equivalent to {@link
77-
* CloseableHttpAsyncClient#execute(SimpleHttpRequest, FutureCallback)}.
82+
* Convenience method for {@link #execute(SimpleHttpRequest, HttpContext)}, equivalent to
83+
* {@link CloseableHttpAsyncClient#execute(SimpleHttpRequest, FutureCallback)}.
7884
*/
7985
default Publisher<SimpleHttpResponse> execute(@Nonnull SimpleHttpRequest request) {
8086
return execute(request, null);
8187
}
8288

8389
/**
84-
* Execute the given request and get a streaming response body as a {@link Publisher} of {@link
85-
* ByteBuffer}s. The returning {@link Publisher} completes with exactly 1 element. The {@link
86-
* Publisher} within the returning {@link Publisher} may contain 0 to n elements.
90+
* Execute the given request and get a streaming response body as a {@link Publisher} of
91+
* {@link ByteBuffer}s. The returning {@link Publisher} completes with exactly 1 element. The
92+
* {@link Publisher} within the returning {@link Publisher} may contain 0 to n elements.
8793
*/
8894
Publisher<Message<HttpResponse, Publisher<ByteBuffer>>> streamingExecute(
8995
@Nonnull AsyncRequestProducer requestProducer,
9096
@Nullable HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
9197
@Nullable HttpContext context);
9298

9399
/**
94-
* Convenience method for {@link #streamingExecute(AsyncRequestProducer, HandlerFactory,
95-
* HttpContext)}
100+
* Convenience method for
101+
* {@link #streamingExecute(AsyncRequestProducer, HandlerFactory, HttpContext)}
96102
*/
97103
default Publisher<Message<HttpResponse, Publisher<ByteBuffer>>> streamingExecute(
98104
@Nonnull AsyncRequestProducer requestProducer, @Nullable HttpContext context) {
99105
return streamingExecute(requestProducer, null, context);
100106
}
101107

102108
/**
103-
* Convenience method for {@link #streamingExecute(AsyncRequestProducer, HandlerFactory,
104-
* HttpContext)}
109+
* Convenience method for
110+
* {@link #streamingExecute(AsyncRequestProducer, HandlerFactory, HttpContext)}
105111
*/
106112
default Publisher<Message<HttpResponse, Publisher<ByteBuffer>>> streamingExecute(
107113
@Nonnull AsyncRequestProducer requestProducer) {
108114
return streamingExecute(requestProducer, null);
109115
}
110116

111117
/**
112-
* Execute a simple in-memory request and get a streaming response. Convenience method for {@link
113-
* #streamingExecute(AsyncRequestProducer, HandlerFactory, HttpContext)}
118+
* Execute a simple in-memory request and get a streaming response. Convenience method for
119+
* {@link #streamingExecute(AsyncRequestProducer, HandlerFactory, HttpContext)}
114120
*/
115121
default Publisher<Message<HttpResponse, Publisher<ByteBuffer>>> streamingExecute(
116122
@Nonnull SimpleHttpRequest request, @Nullable HttpContext context) {
117123
return streamingExecute(SimpleRequestProducer.create(request), context);
118124
}
119125

120126
/**
121-
* Convenience method for {@link #streamingExecute(AsyncRequestProducer, HandlerFactory,
122-
* HttpContext)}
127+
* Convenience method for
128+
* {@link #streamingExecute(AsyncRequestProducer, HandlerFactory, HttpContext)}
123129
*/
124130
default Publisher<Message<HttpResponse, Publisher<ByteBuffer>>> streamingExecute(
125131
@Nonnull SimpleHttpRequest request) {

src/main/java/com/saasquatch/client5reactive/HttpReactiveClientImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.saasquatch.client5reactive;
22

3+
import io.reactivex.rxjava3.core.Maybe;
34
import java.nio.ByteBuffer;
45
import java.util.Objects;
6+
import javax.annotation.Nonnull;
57
import javax.annotation.Nullable;
68
import org.apache.hc.client5.http.async.HttpAsyncClient;
79
import org.apache.hc.core5.http.HttpResponse;
@@ -13,9 +15,6 @@
1315
import org.apache.hc.core5.http.protocol.HttpContext;
1416
import org.apache.hc.core5.reactive.ReactiveResponseConsumer;
1517
import org.reactivestreams.Publisher;
16-
import io.reactivex.rxjava3.core.Maybe;
17-
18-
import javax.annotation.Nonnull;
1918

2019
/**
2120
* Concrete implementation of {@link HttpReactiveClient}.

src/main/java/com/saasquatch/client5reactive/HttpReactiveClients.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ private HttpReactiveClients() {}
1919
/**
2020
* Create a {@link HttpReactiveClient} from a given {@link HttpAsyncClient}. Note that the created
2121
* {@link HttpReactiveClient} is simply a wrapper of the {@link HttpAsyncClient} and does not
22-
* support state management, so you'll need to manage the state of the given {@link
23-
* HttpAsyncClient} yourself by calling {@link CloseableHttpAsyncClient#start()}, {@link
24-
* CloseableHttpAsyncClient#close()}, etc.
22+
* support state management, so you'll need to manage the state of the given
23+
* {@link HttpAsyncClient} yourself by calling {@link CloseableHttpAsyncClient#start()},
24+
* {@link CloseableHttpAsyncClient#close()}, etc.
2525
*/
2626
@Nonnull
2727
public static HttpReactiveClient create(@Nonnull HttpAsyncClient httpAsyncClient) {

src/test/java/com/saasquatch/client5reactive/FutureCallbacksTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.saasquatch.client5reactive;
22

3+
import io.reactivex.rxjava3.core.Maybe;
34
import java.io.IOException;
45
import java.util.concurrent.CancellationException;
56
import org.apache.hc.core5.concurrent.BasicFuture;
67
import org.junit.jupiter.api.Test;
7-
import io.reactivex.rxjava3.core.Maybe;
88

99
public class FutureCallbacksTests {
1010

src/test/java/com/saasquatch/client5reactive/examples/Example.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void main(String[] args) throws Exception {
2424
final HttpReactiveClient reactiveClient = HttpReactiveClients.create(asyncClient);
2525
// Execute a simple in-memory request
2626
Single.fromPublisher(
27-
reactiveClient.execute(SimpleRequestBuilder.get("https://www.example.com").build()))
27+
reactiveClient.execute(SimpleRequestBuilder.get("https://www.example.com").build()))
2828
.doOnSuccess(response -> {
2929
// Get the response status and body in memory
3030
System.out.println(response.getCode());
@@ -35,7 +35,7 @@ public static void main(String[] args) throws Exception {
3535
// Execute a streaming request
3636
// In this case, the request is a simple in-memory request without a request body
3737
Single.fromPublisher(reactiveClient.streamingExecute(
38-
SimpleRequestBuilder.get("https://www.example.com").build()))
38+
SimpleRequestBuilder.get("https://www.example.com").build()))
3939
.flatMapPublisher(message -> {
4040
// Get the status before subscribing to the streaming body
4141
System.out.println(message.getHead().getCode());

0 commit comments

Comments
 (0)