Coder Social home page Coder Social logo

http-grpc-spring-web's Introduction

http-grpc-spring-web

A simplistic spring-web component that automatically configures spring-mvc controllers that transcodes HTTP requests, invokes corresponding gRPC service method and transcodes the reply back to HTTP response, with little configuration. Inspired by envoy HTTP to gRPC transcoder.

Usage

Show me how: refer to the module example with its tests.

Dependency

Maven:

<dependency>
  <groupId>io.github.kenix</groupId>
  <artifactId>http-grpc-spring-web</artifactId>
  <version>0.1.0-rc.4</version>
</dependency>

Gradle:

dependencies {
  implementation 'io.github.kenix:http-grpc-spring-web:0.1.0-rc.4'
}

Plumbing

After implementing a gRPC service, provide following beans:

HttpGrpcMapper responsible for discovering gRPC services and registering transcoder controllers

GrpcServerDescriptor used by HttpGrpcMapper to discover gRPC services. Currently, only support single server. If necessary, can easily support multiple servers.

  • List<FileDescriptor> is mandatory in order to find all message types of gRPC requests. TODO: either injection or enabling ProtoReflectionService

  • one of following alternatives:

    1. List<ServerMethodDefinition> transcoded call is made directly

    2. gRPC server port and one of following:

      1. a gRPC global server interceptor ServerMethodDefinitionInterceptor and enabling gRPC HealthService Invoked the first time (service health check) it will collect all ServerMethodDefinitions, after that only forward calls. This enables direct transcoded calls.
      2. nothing else, transcoded call will not be direct, but routed internally using an embedded gRPC client. This has performance impact.

Integration

  • distributed tracing: out of the box with spring-cloud-starter-sleuth, see also module client

TODO

Refer to open issues.

http-grpc-spring-web's People

Contributors

kenix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

3ldiablo

http-grpc-spring-web's Issues

support http rule '/v1/{name=messages/*}'

Most probably via SimpleUrlHandlerMapping, for http.proto:

// Example:
//
//     service Messaging {
//       rpc GetMessage(GetMessageRequest) returns (Message) {
//         option (google.api.http) = {
//             get: "/v1/{name=messages/*}"
//         };
//       }
//     }
//     message GetMessageRequest {
//       string name = 1; // Mapped to URL path.
//     }
//     message Message {
//       string text = 1; // The resource content.
//     }
//
// This enables an HTTP REST to gRPC mapping as below:
//
// HTTP | gRPC
// -----|-----
// `GET /v1/messages/123456`  | `GetMessage(name: "messages/123456")`

do initial commit

Extract experiment codes into auto-configuration java-library and make it available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.