Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Merino García committed Nov 21, 2023
2 parents 4ffe9e9 + 40f59f1 commit 87658b9
Show file tree
Hide file tree
Showing 92 changed files with 1,879 additions and 1,897 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ Processes.deploy_undeploy avgt 10 2.907 ± 0.658 s/op

## <a name="requirements"><a/> Requirements

Java 11 or greater
Java 17 or greater

## <a name="installation"><a/> Installation

Expand All @@ -1122,7 +1122,7 @@ Java 11 or greater
<dependency>
<groupId>com.github.imrafaelmerino</groupId>
<artifactId>vertx-effect</artifactId>
<version>3.0.1</version>
<version>4.0.0</version>
</dependency>
```

Expand Down
11 changes: 2 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<MAVEN-COMPILER-PLUGIN.SOURCE>17</MAVEN-COMPILER-PLUGIN.SOURCE>
<MAVEN-COMPILER-PLUGIN.TARGET>17</MAVEN-COMPILER-PLUGIN.TARGET>
<VERTX-VERSION>4.4.6</VERTX-VERSION>
<VERTX-VERSION>4.5.0</VERTX-VERSION>
<JAVA-FUN.VERSION>1.3.2</JAVA-FUN.VERSION>
<VERTX.JSON-VALUES.VERSION>1.0.0</VERTX.JSON-VALUES.VERSION>
<MAVEN-JAR-PLUGIN.VERSION>3.2.0</MAVEN-JAR-PLUGIN.VERSION>
Expand All @@ -54,13 +54,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${MAVEN-JAR-PLUGIN.VERSION}</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>vertx.effect</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -97,7 +90,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>${MAVEN-JAVADOC-PLUGIN.VERSION}</version>
<configuration>
<source>11</source>
<source>${MAVEN-COMPILER-PLUGIN.SOURCE}</source>
</configuration>
<executions>
<execution>
Expand Down
83 changes: 31 additions & 52 deletions src/main/java/vertx/effect/AbstractHttpClientModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.function.Consumer;

import java.util.stream.Collectors;

import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE;
Expand All @@ -30,6 +29,21 @@

public abstract class AbstractHttpClientModule extends VertxModule {

protected final HttpClientOptions httpOptions;
protected final String httpClientAddress;
protected Lambdac<JsObj, JsObj> httpClient;

public AbstractHttpClientModule(final HttpClientOptions options,
final String address
) {
if (requireNonNull(address).isBlank())
throw new IllegalArgumentException("address is empty");

this.httpClientAddress = address;
this.httpOptions = requireNonNull(options);

}

private static JsObj toJsObj(Buffer buffer, HttpClientResponse httpResp) {
return STATUS_CODE_LENS.set.apply(httpResp.statusCode())
.andThen(STATUS_MESSAGE_OPT.set.apply(httpResp.statusMessage()))
Expand Down Expand Up @@ -79,22 +93,6 @@ private static ReplyException getHttpReplyException(Throwable exc) {
}
}


protected final HttpClientOptions httpOptions;
protected final String httpClientAddress;
protected Lambdac<JsObj, JsObj> httpClient;

public AbstractHttpClientModule(final HttpClientOptions options,
final String address
) {
if (requireNonNull(address).isBlank())
throw new IllegalArgumentException("address is empty");

this.httpClientAddress = address;
this.httpOptions = requireNonNull(options);

}

private static JsArray cookies2JsArray(final List<String> cookies) {
if (cookies == null || cookies.isEmpty()) return JsArray.empty();
return JsArray.ofIterable(cookies.stream()
Expand All @@ -119,37 +117,20 @@ Consumer<Message<JsObj>> consumer(final HttpClient client) {
reqEvent.host = options.getHost();

switch (type) {
case 0:
execReq(client, message, reqEvent, options, GET);
break;
case 1:
execBodyReq(client, message, reqEvent, HttpReq.BYTES_BODY_LENS.get.apply(req), options, POST);
break;
case 2:
execBodyReq(client, message, reqEvent, HttpReq.BYTES_BODY_LENS.get.apply(req), options, PUT);
break;
case 3:
execReq(client, message, reqEvent, options, DELETE);
break;
case 4:
execReq(client, message, reqEvent, options, OPTIONS);
break;
case 5:
execReq(client, message, reqEvent, options, HEAD);
break;
case 6:
execReq(client, message, reqEvent, options, TRACE);
break;
case 7:
execBodyReq(client, message, reqEvent, HttpReq.BYTES_BODY_LENS.get.apply(req), options, PATCH);
break;

default:
message.reply(new ReplyException(RECIPIENT_FAILURE,
HTTP_METHOD_NOT_IMPLEMENTED_CODE,
"The method type " + type + " is not supported. Supported types are in enum HttpReqBuilder.TYPE."
)
);
case 0 -> execReq(client, message, reqEvent, options, GET);
case 1 -> execBodyReq(client, message, reqEvent, HttpReq.BYTES_BODY_LENS.get.apply(req), options, POST);
case 2 -> execBodyReq(client, message, reqEvent, HttpReq.BYTES_BODY_LENS.get.apply(req), options, PUT);
case 3 -> execReq(client, message, reqEvent, options, DELETE);
case 4 -> execReq(client, message, reqEvent, options, OPTIONS);
case 5 -> execReq(client, message, reqEvent, options, HEAD);
case 6 -> execReq(client, message, reqEvent, options, TRACE);
case 7 ->
execBodyReq(client, message, reqEvent, HttpReq.BYTES_BODY_LENS.get.apply(req), options, PATCH);
default -> message.reply(new ReplyException(RECIPIENT_FAILURE,
HTTP_METHOD_NOT_IMPLEMENTED_CODE,
"The method type " + type + " is not supported. Supported types are in enum HttpReqBuilder.TYPE."
)
);
}
};
}
Expand Down Expand Up @@ -271,9 +252,7 @@ protected final void initialize() {

@Override
protected final void deploy() {
this.deployConsumer(
httpClientAddress,
consumer(vertx.createHttpClient(httpOptions))
);
this.deployConsumer(httpClientAddress,
consumer(vertx.createHttpClient(httpOptions)));
}
}
210 changes: 0 additions & 210 deletions src/main/java/vertx/effect/AbstractVIO.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/vertx/effect/AllExp.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import static java.util.Objects.requireNonNull;

public abstract class AllExp extends Exp<Boolean> {
public abstract sealed class AllExp extends Exp<Boolean> permits AllExpPar, AllExpSeq {

@SafeVarargs
public static AllExp par(final VIO<Boolean> a,
Expand All @@ -23,7 +23,7 @@ public static AllExp seq(final VIO<Boolean> a,
) {
List<VIO<Boolean>> exps = new ArrayList<>();
exps.add(requireNonNull(a));
for (final VIO<Boolean> other : others) exps.add(requireNonNull(other));
for (VIO<Boolean> other : others) exps.add(requireNonNull(other));
return new AllExpSeq(exps);
}

Expand Down

0 comments on commit 87658b9

Please sign in to comment.