grpc-core

Jackstaff gRPC Core: A java RPC framework, Smooth and friendly use of gRPC, Better gRPC

License

License

Categories

Categories

gRPC Net Networking
GroupId

GroupId

org.jackstaff.grpc
ArtifactId

ArtifactId

grpc-core
Last Version

Last Version

2.0.13
Release Date

Release Date

Type

Type

jar
Description

Description

grpc-core
Jackstaff gRPC Core: A java RPC framework, Smooth and friendly use of gRPC, Better gRPC
Project URL

Project URL

https://github.com/jackstaff/grpc
Source Code Management

Source Code Management

https://github.com/jackstaff/grpc

Download grpc-core

How to add to project

<!-- https://jarcasting.com/artifacts/org.jackstaff.grpc/grpc-core/ -->
<dependency>
    <groupId>org.jackstaff.grpc</groupId>
    <artifactId>grpc-core</artifactId>
    <version>2.0.13</version>
</dependency>
// https://jarcasting.com/artifacts/org.jackstaff.grpc/grpc-core/
implementation 'org.jackstaff.grpc:grpc-core:2.0.13'
// https://jarcasting.com/artifacts/org.jackstaff.grpc/grpc-core/
implementation ("org.jackstaff.grpc:grpc-core:2.0.13")
'org.jackstaff.grpc:grpc-core:jar:2.0.13'
<dependency org="org.jackstaff.grpc" name="grpc-core" rev="2.0.13">
  <artifact name="grpc-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jackstaff.grpc', module='grpc-core', version='2.0.13')
)
libraryDependencies += "org.jackstaff.grpc" % "grpc-core" % "2.0.13"
[org.jackstaff.grpc/grpc-core "2.0.13"]

Dependencies

compile (5)

Group / Artifact Type Version
io.grpc : grpc-netty-shaded jar
io.grpc : grpc-protobuf jar
io.grpc : grpc-stub jar
io.protostuff : protostuff-core jar 1.7.2
io.protostuff : protostuff-runtime jar 1.7.2

Project Modules

There are no modules declared in this project.

Jackstaff gRPC framework

Quick Starts / Advance Usage / Smooth and friendly use of gRPC / Origin

Quick Starts:

Step 0: Import grpc-spring-boot-starter in pom.xml. jdk1.8

<!-- https://mvnrepository.com/artifact/org.jackstaff.grpc/grpc-spring-boot-starter -->
<dependency>
    <groupId>org.jackstaff.grpc</groupId>
    <artifactId>grpc-spring-boot-starter</artifactId>
    <version>2.0.13</version>
</dependency>

Step 1: Define protocol interface:

import java.util.function.Consumer;

public interface HelloService {

    String sayHello(String greeting); //Unary RPCs

    void lotsOfReplies(String greeting, Consumer<String> replies);//Server streaming RPCs

    Consumer<String> lotsOfGreetings(List<String> friends); //Client streaming RPCs

    Consumer<String> bidiHello(List<String> friends, Consumer<String> replies); //Bidirectional streaming RPCs

}

Step 2: Implements protocol interface(at "server side micro service" project):

import org.jackstaff.grpc.annotation.Server;
@Server(HelloService.class)
public class MyHelloService implements HelloService {

    @Override
    public String sayHello(String greeting) {
        //todo
        return "reply " + greeting;
    }

    @Override
    public void lotsOfReplies(String greeting, Consumer<String> replies) {
        //todo
        replies.accept("hi "+ greeting);
        replies.accept(":)");
    }

    @Override
    public Consumer<String> lotsOfGreetings(List<String> friends) {
        //todo
        return s-> System.out.println(s);
    }

    @Override
    public Consumer<String> bidiHello(List<String> friends, Consumer<String> replies) {
        //todo
        CompletableFuture.runAsync(()-> friends.forEach(friend->replies.accept("hi "+ friend)));
        return s-> System.out.println(s);
    }

}

Step 3: Use protocol interface (at "client side micro service" project):

import org.jackstaff.grpc.annotation.Client;

@Service
public class MyClientService {

    @Client("my-server") 
    private HelloService helloService;

    public String sayHello(String greeting){
        return helloService.sayHello(greeting);
    }
    
}

Step 4: Config "client side " application.yml:

spring:
  grpc:
    client:
      my-server:
        host: localhost
        port: 9000

Step 5: Config "server side " application.yml:

spring:
  grpc:
    server:
      port: 9000

done.

Versions

Version
2.0.13
2.0.12
2.0.11
2.0.10
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
1.0.3
1.0.2
1.0.1
1.0