-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2631 from hosuaby/feature/feign-vertx
Integrate Feign Vertx into the main project
- Loading branch information
Showing
34 changed files
with
3,367 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Feign Vertx | ||
|
||
Implementation of Feign on Vertx. Brings you the best of two worlds together : | ||
concise syntax of Feign to write client side API on fast, asynchronous and | ||
non-blocking HTTP client of Vertx. | ||
|
||
## Installation | ||
|
||
### With Maven | ||
|
||
```xml | ||
<dependencies> | ||
... | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-vertx</artifactId> | ||
<version>14.0</version> | ||
</dependency> | ||
... | ||
</dependencies> | ||
``` | ||
|
||
### With Gradle | ||
|
||
```groovy | ||
compile group: 'io.github.openfeign', name: 'feign-vertx', version: '14.0' | ||
``` | ||
|
||
## Compatibility | ||
|
||
Feign | Vertx | ||
---------------------- | ---------------------- | ||
14.x | 4.x | ||
|
||
## Usage | ||
|
||
Write Feign API as usual, but every method of interface must return | ||
`io.vertx.core.Future`. | ||
|
||
```java | ||
@Headers({ "Accept: application/json" }) | ||
interface IcecreamServiceApi { | ||
|
||
@RequestLine("GET /icecream/flavors") | ||
Future<Collection<Flavor>> getAvailableFlavors(); | ||
|
||
@RequestLine("GET /icecream/mixins") | ||
Future<Collection<Mixin>> getAvailableMixins(); | ||
|
||
@RequestLine("POST /icecream/orders") | ||
@Headers("Content-Type: application/json") | ||
Future<Bill> makeOrder(IceCreamOrder order); | ||
|
||
@RequestLine("GET /icecream/orders/{orderId}") | ||
Future<IceCreamOrder> findOrder(@Param("orderId") int orderId); | ||
|
||
@RequestLine("POST /icecream/bills/pay") | ||
@Headers("Content-Type: application/json") | ||
Future<Void> payBill(Bill bill); | ||
} | ||
``` | ||
Build the client : | ||
|
||
```java | ||
Vertx vertx = Vertx.vertx(); // get Vertx instance | ||
|
||
/* Create instance of your API */ | ||
IcecreamServiceApi icecreamApi = VertxFeign | ||
.builder() | ||
.vertx(vertx) // provide vertx instance | ||
.encoder(new JacksonEncoder()) | ||
.decoder(new JacksonDecoder()) | ||
.target(IcecreamServiceApi.class, "http://www.icecreame.com"); | ||
|
||
/* Execute requests asynchronously */ | ||
Future<Collection<Flavor>> flavorsFuture = icecreamApi.getAvailableFlavors(); | ||
Future<Collection<Mixin>> mixinsFuture = icecreamApi.getAvailableMixins(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright © 2012 The Feign Authors (feign@commonhaus.dev) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" 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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>13.6-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>feign-vertx</artifactId> | ||
|
||
<name>Feign Vertx</name> | ||
<description>Implementation of Feign on Vertx web client.</description> | ||
|
||
<properties> | ||
<vertx.version>4.5.10</vertx.version> | ||
<jackson.version>2.12.0</jackson.version> | ||
<slf4j-log4j12.version>1.8.0-beta0</slf4j-log4j12.version> | ||
<wiremock.version>2.35.1</wiremock.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson</groupId> | ||
<artifactId>jackson-bom</artifactId> | ||
<version>${jackson.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-core</artifactId> | ||
</dependency> | ||
|
||
<!-- Vertx --> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-core</artifactId> | ||
<version>${vertx.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Tests --> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-junit5</artifactId> | ||
<version>${vertx.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-jackson</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-slf4j</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>${slf4j-log4j12.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.github.tomakehurst</groupId> | ||
<artifactId>wiremock-jre8</artifactId> | ||
<version>${wiremock.version}</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.junit</groupId> | ||
<artifactId>junit-bom</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env zsh | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' | ||
|
||
CHECK_CHAR='\U2713' | ||
CROSS_CHAR='\U2717' | ||
|
||
function print_result() { | ||
version=$1 | ||
result=$2 | ||
|
||
if [[ $result == 0 ]]; | ||
then | ||
mark=$CHECK_CHAR | ||
color=$GREEN | ||
else | ||
mark=$CROSS_CHAR | ||
color=$RED | ||
fi | ||
|
||
echo "\t${color}${version} ${mark}${NC}" | ||
} | ||
|
||
feign_versions=( "12.5" "13.5" ) | ||
|
||
for feign_version in $feign_versions; do | ||
echo "Tests with Feign ${version}:" | ||
|
||
printf "\tRun tests with Feign %s...\n" "${feign_version}" | ||
mvn clean compile test -Dfeign.version="$feign_version" &> /dev/null | ||
print_result "$feign_version" $? | ||
done | ||
|
||
declare -A vertx_versions | ||
vertx_versions=( [v40x]="4.0.x", [v41x]="4.1.x", [v42x]="4.2.x", [v43x]="4.3.x", [v44x]="4.4.x", [v45x]="4.5.x" ) | ||
v40x=( "4.0.2" ) | ||
v41x=( "4.1.8" ) | ||
v42x=( "4.2.7" ) | ||
v43x=( "4.3.2" ) | ||
v44x=( "4.4.9" ) | ||
v45x=( "4.5.10" ) | ||
|
||
for version in ${(k)vertx_versions}; do | ||
echo "Tests with Vertx ${vertx_versions[${version}]}:" | ||
|
||
for vertx_version in ${(P)version}; do | ||
printf "\tRun tests with Vertx %s...\n" "${vertx_version}" | ||
mvn clean compile test -Dvertx.version="$vertx_version" &> /dev/null | ||
print_result "$vertx_version" $? | ||
done | ||
done |
Oops, something went wrong.