All Projects → yidongnan → Grpc Spring Boot Starter

yidongnan / Grpc Spring Boot Starter

Licence: mit
Spring Boot starter module for gRPC framework.

Programming Languages

java
68154 projects - #9 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Grpc Spring Boot Starter

Grpc Spring Boot Starter
Spring Boot starter module for gRPC framework.
Stars: ✭ 1,829 (-16.48%)
Mutual labels:  grpc, spring-boot, spring, spring-cloud, spring-boot-starter, grpc-framework
Spring Thrift Api Gateway
Gateway for Apache Thrift requests processing that is built on Spring Cloud stack
Stars: ✭ 38 (-98.26%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-boot-starter
Spring Cloud Cli
Spring Cloud CLI features
Stars: ✭ 139 (-93.65%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Study
spring-cloud学习
Stars: ✭ 108 (-95.07%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Example
Stars: ✭ 111 (-94.93%)
Mutual labels:  spring-boot, spring, spring-cloud
Springbootdemo
springBoot demo
Stars: ✭ 97 (-95.57%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Microservices Development
Spring Cloud Microservices Development.《Spring Cloud 微服务架构开发实战》
Stars: ✭ 106 (-95.16%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Boot Examples
🥗​ Spring/SpringBoot/SpringCloud 实践学习案例,从入门到精通,持续更新中,欢迎交流学习🍺 !
Stars: ✭ 110 (-94.98%)
Mutual labels:  spring-boot, spring, spring-cloud
Java Spring Web
OpenTracing Spring Web instrumentation
Stars: ✭ 89 (-95.94%)
Mutual labels:  spring-boot, spring, spring-cloud
Wicket Spring Boot
Spring Boot starter for Apache Wicket
Stars: ✭ 117 (-94.66%)
Mutual labels:  spring-boot, spring, spring-boot-starter
Spring Cloud Build
Common build concerns, shared plugin configuration, etc. for Spring Cloud modules
Stars: ✭ 114 (-94.79%)
Mutual labels:  spring-boot, spring, spring-cloud
Bucket4j Spring Boot Starter
Spring Boot Starter for Bucket4j
Stars: ✭ 127 (-94.2%)
Mutual labels:  spring-boot, spring, spring-boot-starter
Spring Cloud Yes
基于Spring Cloud的快速开发脚手架&最佳实践总结
Stars: ✭ 138 (-93.7%)
Mutual labels:  spring-boot, spring, spring-cloud
Limiter
一个注解使你的SpringBoot项目获得分布式锁和限流器能力
Stars: ✭ 93 (-95.75%)
Mutual labels:  spring-boot, spring, spring-cloud
Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+2402.15%)
Mutual labels:  spring-boot, spring, spring-cloud
Eureka Consul Adapter
This project contains a Spring Boot Starter that registers HTTP endpoints on a Spring Cloud Eureka server to support Prometheus's service discovery mechanism for Consul (<consul_sd_config>)
Stars: ✭ 93 (-95.75%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Sleuth
Distributed tracing for spring cloud
Stars: ✭ 1,531 (-30.09%)
Mutual labels:  spring-boot, spring, spring-cloud
Telegram Spring Boot Starter
Telegram Bot API Spring Boot Starter
Stars: ✭ 79 (-96.39%)
Mutual labels:  spring-boot, spring, spring-boot-starter
Spring Cloud Cloudfoundry
Integration between Cloudfoundry and the Spring Cloud APIs
Stars: ✭ 83 (-96.21%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Flycloud
🔥🔥🔥FlyClould 微服务实战项目框架,在该框架中,包括了用 Spring Cloud 构建微服务的一系列基本组件和框架,对于后台服务框架的搭建有很大的参考价值,大家可以参考甚至稍加修改可以直接应用于自己的实际的项目开发中,该项目没有采用Maven进行项目构建,Maven通过xml进行依赖管理,导致整个配置文件太过臃肿,另外灵活性也不是很强,所以我采用Gradle进行项目构建和依赖管理,在FlyTour项目中我们见证了Gradle的强大,通过简单的一些配置就可以轻松的实现组件化的功能。该项目共有11个Module工程。其中10个位微服务工程,这10个微服务工程构成了一个完整的微服务系统,微服务系统包含了8个基础服务,提供了一整套微服务治理功能,他们分别是配置中心module_c…
Stars: ✭ 1,514 (-30.87%)
Mutual labels:  spring-boot, spring, spring-cloud

gRPC Spring Boot Starter

Build master branch Maven Central with version prefix filter MIT License Crowdin

Client-Javadoc Server-Javadoc Common-Javadoc

README: English | 中文

Documentation: English | 中文

Features

  • Automatically configures and runs the gRPC server with your @GrpcService implementations

  • Automatically creates and manages your grpc channels and stubs with @GrpcClient

  • Supports other grpc-java flavors (e.g. Reactive gRPC (RxJava), grpc-kotlin, ...)

    • Server-side: Should work for all grpc-java flavors (io.grpc.BindableService based)
    • Client-side: Requires custom StubFactorys
      Currently build-in support:
      • grpc-java
      • (Please report missing ones, so we can add support for them)
  • Supports Spring-Security

  • Supports Spring Cloud

    • Server-side: Adds grpc-port information to the service registration details
      Currently natively supported:
    • Client-side: Reads the service's target addresses from spring's DiscoveryClient (all flavors)
  • Supports Spring Sleuth as distributed tracing solution
    (If brave-instrumentation-grpc is present)

  • Supports global and custom gRPC server/client interceptors

  • Automatic metric support (micrometer/actuator based)

  • Also works with (non-shaded) grpc-netty

Versions

The latest version is 2.13.0.RELEASE it was compiled with spring-boot 2.4.5 and spring-cloud 2020.0.2 but it is also compatible with a large variety of other versions. An overview of all versions and their respective library versions can be found in our documentation.

Note: This project can also be used without Spring-Boot, however that requires some manual bean configuration.

Usage

gRPC Server + Client

To add a dependency using Maven, use the following:

<dependency>
  <groupId>net.devh</groupId>
  <artifactId>grpc-spring-boot-starter</artifactId>
  <version>2.13.0.RELEASE</version>
</dependency>

To add a dependency using Gradle:

dependencies {
  implementation 'net.devh:grpc-spring-boot-starter:2.13.0.RELEASE'
}

gRPC Server

To add a dependency using Maven, use the following:

<dependency>
  <groupId>net.devh</groupId>
  <artifactId>grpc-server-spring-boot-starter</artifactId>
  <version>2.13.0.RELEASE</version>
</dependency>

To add a dependency using Gradle:

dependencies {
  implementation 'net.devh:grpc-server-spring-boot-starter:2.13.0.RELEASE'
}

Annotate your server interface implementation(s) with @GrpcService

@GrpcService
public class GrpcServerService extends GreeterGrpc.GreeterImplBase {

    @Override
    public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = HelloReply.newBuilder().setMessage("Hello ==> " + req.getName()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }

}

By default, the grpc server will listen to port 9090. These and other settings can be changed via Spring's property mechanism. The server uses the grpc.server. prefix.

Refer to our documentation for more details.

gRPC Client

To add a dependency using Maven, use the following:

<dependency>
  <groupId>net.devh</groupId>
  <artifactId>grpc-client-spring-boot-starter</artifactId>
  <version>2.13.0.RELEASE</version>
</dependency>

To add a dependency using Gradle:

dependencies {
  compile 'net.devh:grpc-client-spring-boot-starter:2.13.0.RELEASE'
}

Annotate a field of your grpc client stub with @GrpcClient(serverName)

  • Do not use in conjunction with @Autowired or @Inject

    @GrpcClient("gRPC server name")
    private GreeterGrpc.GreeterBlockingStub greeterStub;

Note: You can use the same grpc server name for multiple channels and also different stubs (even with different interceptors).

Then you can send queries to your server just like this:

HelloReply response = stub.sayHello(HelloRequest.newBuilder().setName(name).build());

It is possible to configure the target address for each client individually. However in some cases, you can just rely on the default configuration. You can customize the default url mapping via NameResolver.Factory beans. If you don't configure that bean, then the default uri will be guessed using the default scheme and the name (e.g.: dns:/<name>):

These and other settings can be changed via Spring's property mechanism. The clients use the grpc.client.(serverName). prefix.

Refer to our documentation for more details.

Running with (non-shaded) grpc-netty

This library supports both grpc-netty and grpc-netty-shaded. The later one might prevent conflicts with incompatible grpc-versions or conflicts between libraries that require different versions of netty.

Note: If the shaded netty is present on the classpath, then this library will always favor it over the non-shaded grpc-netty one.

You can use it with Maven like this:

<dependency>
    <groupId>io.grpc</groupId>
    <artifactId>grpc-netty</artifactId>
    <version>${grpcVersion}</version>
</dependency>

<!-- For both -->
<dependency>
    <groupId>net.devh</groupId>
    <artifactId>grpc-spring-boot-starter</artifactId>
    <version>...</version>
    <exclusions>
        <exclusion>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- For the server (only) -->
<dependency>
    <groupId>net.devh</groupId>
    <artifactId>grpc-server-spring-boot-starter</artifactId>
    <version>...</version>
    <exclusions>
        <exclusion>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- For the client (only) -->
<dependency>
    <groupId>net.devh</groupId>
    <artifactId>grpc-client-spring-boot-starter</artifactId>
    <version>...</version>
    <exclusions>
        <exclusion>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
        </exclusion>
    </exclusions>
</dependency>

and like this when using Gradle:

implementation "io.grpc:grpc-netty:${grpcVersion}"

implementation 'net.devh:grpc-spring-boot-starter:...' exclude group: 'io.grpc', module: 'grpc-netty-shaded' // For both
implementation 'net.devh:grpc-client-spring-boot-starter:...' exclude group: 'io.grpc', module: 'grpc-netty-shaded' // For the client (only)
implementation 'net.devh:grpc-server-spring-boot-starter:...' exclude group: 'io.grpc', module: 'grpc-netty-shaded' // For the server (only)

Example-Projects

Read more about our example projects here.

Troubleshooting

Refer to our documentation for help.

Contributing

Contributions are always welcomed! Please see CONTRIBUTING.md for detailed guidelines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].