forked from qicosmos/rest_rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
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 qicosmos#26 from jovany-wang/java
Support Java client for rest_rpc
- Loading branch information
Showing
18 changed files
with
837 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,9 @@ cmake_install.cmake | |
|
||
# idea | ||
.idea/ | ||
|
||
.DS_Store | ||
*iml | ||
target/ | ||
|
||
build/ |
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
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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
|
||
<groupId>org.restrpc</groupId> | ||
<artifactId>restrpc</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>29.0-jre</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.21</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>7.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.msgpack</groupId> | ||
<artifactId>msgpack-core</artifactId> | ||
<version>0.8.21</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<resources> | ||
<resource> | ||
<directory>native_dependencies</directory> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
java/src/main/java/org/restrpc/client/AsyncRpcFunction.java
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,28 @@ | ||
package org.restrpc.client; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface AsyncRpcFunction { | ||
|
||
CompletableFuture<Object> invoke(Class returnClz); | ||
|
||
<Arg1Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1); | ||
|
||
<Arg1Type, Arg2Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2); | ||
|
||
<Arg1Type, Arg2Type, Arg3Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3); | ||
|
||
|
||
<Arg1Type, Arg2Type, Arg3Type, Arg4Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4); | ||
|
||
<Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5); | ||
|
||
<Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5, Arg6Type arg6); | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
java/src/main/java/org/restrpc/client/AsyncRpcFunctionImpl.java
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,59 @@ | ||
package org.restrpc.client; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class AsyncRpcFunctionImpl implements AsyncRpcFunction { | ||
|
||
private RpcClient rpcClient; | ||
|
||
private String funcName; | ||
|
||
public AsyncRpcFunctionImpl(RpcClient rpcClient, String funcName) { | ||
this.rpcClient = rpcClient; | ||
this.funcName = funcName; | ||
} | ||
|
||
public CompletableFuture<Object> invoke(Class returnClz) { | ||
return internalInvoke(returnClz, new Object[0]); | ||
} | ||
|
||
public <Arg1Type> CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1) { | ||
Object[] args = new Object[] {arg1}; | ||
return internalInvoke(returnClz, args); | ||
} | ||
|
||
public <Arg1Type, Arg2Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2) { | ||
Object[] args = new Object[] {arg1, arg2}; | ||
return internalInvoke(returnClz, args); | ||
} | ||
|
||
public <Arg1Type, Arg2Type, Arg3Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) { | ||
Object[] args = new Object[] {arg1, arg2, arg3}; | ||
return internalInvoke(returnClz, args); | ||
} | ||
|
||
|
||
public <Arg1Type, Arg2Type, Arg3Type, Arg4Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4) { | ||
Object[] args = new Object[] {arg1, arg2, arg3, arg4}; | ||
return internalInvoke(returnClz, args); | ||
} | ||
|
||
public <Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5) { | ||
Object[] args = new Object[] {arg1, arg2, arg3, arg4, arg5}; | ||
return internalInvoke(returnClz, args); | ||
} | ||
|
||
public <Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type> | ||
CompletableFuture<Object> invoke(Class returnClz, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5, Arg6Type arg6) { | ||
Object[] args = new Object[] {arg1, arg2, arg3, arg4, arg5, arg6}; | ||
return internalInvoke(returnClz, args); | ||
} | ||
|
||
private CompletableFuture<Object> internalInvoke(Class returnClz, Object[] args) { | ||
return rpcClient.invoke(returnClz, funcName, args); | ||
} | ||
} |
Oops, something went wrong.