Git Product home page Git Product logo

twirpdemo's Introduction

twirpdemo

This repo was created for a local meetup to show some of the features of the Twirp RPC framework.

Usage

Generate proto code:

protoc  --twirp_out=. --go_out=. proto/rpc.proto

Run the calculator service:

$ go run cmd/calculatorsvc/main.go
2021/11/19 13:13:43 server started at port 8080

Make a request using curl:

$ curl \
  --request "POST" \
  --header 'Content-Type:application/json' \
  --data '{"a": 10, "b": 5}' \
  http://localhost:8080/twirp/Calculator/Add

{"result":15}โŽ

Make a request using generated Go client:

$ go run cmd/calculatorctl/main.go
Result = 15

twirpdemo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

twirpdemo's Issues

Question about Twirp and gRPC

Thanks for the demo first ๐Ÿ… . I have a couple of questions about twirp and demo as follows;

  1. Let say that I am building a public API and generating clients for multiple languages. Is it possible to skip the client generation part for twirp, since I don't want to maintain the client part in the related service implementation folder?
  2. This is partially related to question#1. Client generation seems practical in terms of consuming it on other services, e.g. product service uses customer service client to consume customer endpoints. If you are in a monorepo, do you directly use customer service client in product service by accessing that package? Or you are using replace directive within your productservice/go.mod file?
  3. You can ignore this if you are not using dedicated repo for your microservices. Do you generate a client within the service repo and tag it as client/v1.9.1 and use something like github.com/fatih/customerservice client/v1.9.1 in your product service go mod file?
  4. Have you ever thought to maintain your proto files in a separate repo so that with a simple GitHub action, you can generate lang-specific grpc implementations and use them as a dependency in any client project? e.g. https://github.com/huseyinbabal/demory-proto
  5. Do you think, tracing and observability are easy within twirp? Any plug-and-play integration so that my correlation ids can be autogenerated and passed between services.

Thanks in advance

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.