go-twirp


tags:

  • ready
  • online
  • reviewed
  • microservices
  • go
  • frameworks

twirp

Contents

__Roadmap info from [ roadmap website ] (https://roadmap.sh/golang/go-microservices/twirp) __

Twirp

Twirp is a framework for service-to-service communication emphasizing simplicity and minimalism.It generates routing and serialization from API definition files and lets you focus on your application’ s logic instead of thinking about folderol like HTTP methods and paths and JSON.Twirp is similar to gRPC, but without the custom HTTP server and transport implementations: it runs on the standard library’s extremely-well-tested-and-high-performance net/http Server. It can run on HTTP 1.1, not just http/2, and supports JSON serialization for easy debugging.

Visit the following resources to learn more:

Twirp__

  • Purpose: A lightweight RPC framework using Protobuf or JSON.
  • Best For: Simpler RPC-based microservices with minimal setup and overhead.

Example:

twirpHandler := pb.NewHaberdasherServer(&Server{}, nil)
http.ListenAndServe(":8080", twirpHandler)

Twirp__ - Lightweight RPC Framework

Solution Example: Simple Microservices for a SaaS Platform

  • Use Case: A SaaS platform with simple, small microservices (e.g., billing, authentication) that need efficient communication.
  • Framework Usage: Twirp allows each service to use lightweight RPC, supporting both Protobuf and JSON for simple inter-service communication.
  • Workflow:
  1. BillingService communicates with AuthService using Twirp for authentication checks before processing payments.
  2. Services communicate over HTTP with minimal overhead using Protobuf for serialization.

Example:

twirpHandler := pb.NewBillingServer(&Server{}, nil)
http.ListenAndServe(":8080", twirpHandler)