All Projects → thangchung → Grpcjsontranscoder

thangchung / Grpcjsontranscoder

Licence: mit
A filter which allows a RESTful JSON API client to send requests to .NET web server over HTTP and get proxied to a gRPC service

Projects that are alternatives of or similar to Grpcjsontranscoder

Coolstore Microservices
A full-stack .NET microservices build on Dapr and Tye
Stars: ✭ 1,903 (+1861.86%)
Mutual labels:  rest-api, microservices, grpc, cloud-native, dotnet-core, microservices-architecture
Gloo
The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
Stars: ✭ 3,219 (+3218.56%)
Mutual labels:  microservices, grpc, api-gateway, cloud-native
Kratos
A modular-designed and easy-to-use microservices framework in Go.
Stars: ✭ 15,844 (+16234.02%)
Mutual labels:  rest-api, microservices, grpc, cloud-native
Resgate
A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.
Stars: ✭ 473 (+387.63%)
Mutual labels:  rest-api, microservices, api-gateway, microservices-architecture
Netcorekit
💗 A crafted toolkit for building cloud-native apps on the .NET platform
Stars: ✭ 248 (+155.67%)
Mutual labels:  grpc, cloud-native, dotnet-core, microservices-architecture
Modernarchitectureshop
The Microservices Online Shop is an application with a modern software architecture that is cleanly designed and based on.NET lightweight technologies. The shop has two build variations. The first variant is the classic Microservices Architectural Style. The second one is with Dapr. Dapr has a comprehensive infrastructure for building highly decoupled Microservices; for this reason, I am using Dapr to achieve the noble goal of building a highly scalable application with clean architecture and clean code.
Stars: ✭ 154 (+58.76%)
Mutual labels:  microservices, grpc, dotnet-core, microservices-architecture
Dubbo Go Pixiu
Based on the proxy gateway service of dubbo-go, it solves the problem that the external protocol calls the internal Dubbo cluster. At present, it supports HTTP and gRPC[developing].
Stars: ✭ 124 (+27.84%)
Mutual labels:  microservices, grpc, api-gateway, cloud-native
Netcoremicroservicessample
Sample using micro services in .NET Core 3.1 Focusing on clean code
Stars: ✭ 403 (+315.46%)
Mutual labels:  microservices, api-gateway, dotnet-core, microservices-architecture
Gnes
GNES is Generic Neural Elastic Search, a cloud-native semantic search system based on deep neural network.
Stars: ✭ 1,178 (+1114.43%)
Mutual labels:  microservices, grpc, cloud-native
phalanx
Phalanx is a cloud-native distributed search engine that provides endpoints through gRPC and traditional RESTful API.
Stars: ✭ 192 (+97.94%)
Mutual labels:  grpc, cloud-native, restful-api
Nats.go
Golang client for NATS, the cloud native messaging system.
Stars: ✭ 3,690 (+3704.12%)
Mutual labels:  microservices, cloud-native, microservices-architecture
go-zero
A cloud-native Go microservices framework with cli tool for productivity.
Stars: ✭ 23,294 (+23914.43%)
Mutual labels:  cloud-native, microservices-architecture, restful-api
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (+86.6%)
Mutual labels:  rest-api, restful-api, api-gateway
Grpc Gateway
The gRPC-Gateway is a plugin of the Google protocol buffers compiler protoc. It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC. This server is generated according to the google.api.http annotations in your service definitions.
Stars: ✭ 12,223 (+12501.03%)
Mutual labels:  rest-api, grpc, restful-api
Gokit
Go Examples: From basics to distributed systems
Stars: ✭ 325 (+235.05%)
Mutual labels:  microservices, grpc, restful-api
Run Aspnetcore Microservices
Microservices on .Net platforms which used Asp.Net Web API, Docker, RabbitMQ, MassTransit, Grpc, Ocelot API Gateway, MongoDB, Redis, PostgreSQL, SqlServer, Dapper, Entity Framework Core, CQRS and Clean Architecture implementation. Also includes Cross-Cutting concerns like Implementing Centralized Distributed Logging with Elasticsearch, Kibana and SeriLog, use the HealthChecks with Watchdog, Implement Retry and Circuit Breaker patterns with Polly and so on.. See Microservices Architecture and Step by Step Implementation on .NET Course w/ discount->
Stars: ✭ 406 (+318.56%)
Mutual labels:  rest-api, api-gateway, microservices-architecture
Ocelot
.NET core API Gateway
Stars: ✭ 6,675 (+6781.44%)
Mutual labels:  api-gateway, dotnet-core, microservices-architecture
Steeltoe
Steeltoe .NET Core Components: CircuitBreaker, Configuration, Connectors, Discovery, Logging, Management, and Security
Stars: ✭ 612 (+530.93%)
Mutual labels:  microservices, cloud-native, dotnet-core
Tyk
Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Stars: ✭ 6,968 (+7083.51%)
Mutual labels:  microservices, grpc, api-gateway
Krakend Ce
KrakenD Community Edition. Make your binary of KrakenD API Gateway
Stars: ✭ 245 (+152.58%)
Mutual labels:  microservices, api-gateway, cloud-native

Grpc-Json Transcoder project

Price version

This is a filter that allows a RESTful JSON API client (Ocelot Gateway) to send requests to .NET Web API (Aggregator Service) over HTTP and get proxied to a gRPC service (on the downstream).

This project is inspired by grpc-gateway which is totally for golang, grpc-dynamic-gateway is for nodejs. And especially, Envoy gRPC-JSON transcoder is the best of transcoding in this area, but it is only on the infrastructure level. You also can use it just like my project used at coolstore-microservices. We might use the approach from Microsoft at GrpcHttpApi, but it is not publish in the official release by Microsoft in the meantime.

gRPC parser borrows the idea from Ocelot.GrpcHttpGateway code-based.

Give a Star!

If you liked GrpcJsonTranscoder project or if it helped you, please give a star ⭐️ for this repository. That will not only help strengthen our .NET community but also improve cloud-native apps development skills for .NET developers in around the world. Thank you very much 👍

Check out my blog or say hi on Twitter!

How to run it!

$ docker-compose up

or

$ bash
$ start.sh # I haven't done it yet :p

In the mean time, we open up the visual studio, run multiple projects included OcelotGateway, AggregationRestApi, ProductCatalogGrpcServer and GreatGrpcServer

Test it as below:

# gRPC
$ curl -X GET -H 'content-type: application/grpc' -k http://localhost:5000/say/Bob
$ {"Message":"Hello Bob"}
# gRPC
$ curl -X GET -H 'content-type: application/grpc' -k http://localhost:5000/products
$ {"Products":[{"Id":1,"Name":"product 1","Quantity":52,"Description":"description of product 1"},...]}
# gRPC
$ curl -X POST -H 'content-type: application/grpc' -d '{ "name": "product 1", "quantity": 1, "description": "this is product 1" }' -k http://localhost:5000/products
$ {"Product":{"Id":915,"Name":"product 1 created","Quantity":1,"Description":"this is product 1 created"}}
# REST Api
$ curl -X GET -H 'content-type: application/json' -k http://localhost:5000/weather 
$ [{"date":"2019-08-17T18:34:41.1090164+07:00","temperatureC":-6,"temperatureF":22,"summary":"Sweltering"},{"date":"2019-08-18T18:34:41.1090371+07:00","temperatureC":27,"temperatureF":80,"summary":"Hot"},{"date":"2019-08-19T18:34:41.1090499+07:00","temperatureC":33,"temperatureF":91,"summary":"Balmy"},{"date":"2019-08-20T18:34:41.1090617+07:00","temperatureC":-14,"temperatureF":7,"summary":"Chilly"},{"date":"2019-08-21T18:34:41.1090743+07:00","temperatureC":22,"temperatureF":71,"summary":"Hot"}]

Notes:

  • REST method: content-type: application/json is for REST method on the downstream services.
  • gRPC method: content-type: application/grpc is really important if you call to gRPC endpoint on the downstream services.

How to understand it!

The project aims to .NET community and its ecosystem which leverage the power of Ocelot Gateway which is very powerful in the gateway components were used by various of companies and sample source code when we try to adopt the microservices architecture project.

That's quite simple with only a few steps to make it work :) Create the .NET Core project with Ocelot in place, then put the configuration as below

{
  "ReRoutes": [
    {
      "UpstreamPathTemplate": "/say/{name}",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/Greet.Greeter/SayHello",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "127.0.0.1",
          "Port": 5003
        }
      ]
    },
    {
      "UpstreamPathTemplate": "/products",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/ProductCatalog.Product/GetProducts",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "127.0.0.1",
          "Port": 5002
        }
      ]
    },
    {
      "UpstreamPathTemplate": "/products",
      "UpstreamHttpMethod": [ "Post" ],
      "DownstreamPathTemplate": "/ProductCatalog.Product/CreateProduct",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "127.0.0.1",
          "Port": 5002
        }
      ]
    },
    {
      "UpstreamPathTemplate": "/weather",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/weatherforecast",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 5001
        }
      ]
    }
  ],
  "GlobalConfiguration": {
  }
}

Then in code Program.cs, you only put a few line

var configuration = new OcelotPipelineConfiguration
{
    PreQueryStringBuilderMiddleware = async (ctx, next) =>
    {
        await ctx.HandleGrpcRequestAsync(next);
    }
};

app.UseOcelot(configuration).Wait();

Don't believe what I said. Try it!

We haven't tested it with stream and full-duplex transport protocols yet. So we feel free to contribute by the .NET community.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :p
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].