Skip to content

bchu7796/plaRPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plaRPC

Introduction

plaRPC is a tool that makes developing RPC microservices with Java easier. Users can create a normal Java class and run it as a gRPC server simply with this tool.

Example

Let's say we have an interface "Test":

public interface Test {
    Integer hello();
    Integer helloName(String name);
    Integer square(Integer a);
    Integer sum(Integer a, Integer b);
}

and it's implementation "TestImpl":

public class TestImpl implements Test{
    public Integer hello() {
        System.out.println("hello");
        return 0;
    }

    @Override
    public Integer helloString(String name) {
        System.out.println("hello " + name);
        return 0;
    }

    @Override
    public Integer square(Integer a) {
        return a * a;
    }

    @Override
    public Integer sum(Integer a, Integer b) {
        return a + b;
    }
}

We can now deploy the service by using the following code:

Test test = new TestImpl();
PlaRpcServerApi<Test> server = new PlaRpcServerImpl<>(test);
server.start(5000);

Clients can connect to the service by using the following code:

PlaRpcClientApi<Test> client = new PlaRpcClientImpl<Test>(Test.class, "localhost", 5000);
client.rpc().hello();
client.rpc().helloString("world");
client.rpc().square(10);
client.rpc().sum(10, 10);

About

An easy-to-use RPC interface based on gRPC.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages