trpc

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 1 Imported by: 0

README

tRPC-Gateway

LICENSE

Table of Contents

Introduction

tRPC-Gateway is a business gateway framework in the tRPC ecosystem.

It has the following advantages:

  1. Low integration cost: It is essentially a tRPC-Go service, so it can be deployed like any other tRPC-Go service.
  2. Low entry barrier: It can fully reuse the tRPC ecosystem, including service governance, monitoring and alerting, protocol support, and log querying.
  3. Rich routing strategies: It supports various routing strategies such as exact matching, prefix matching, regular expression matching, fine-grained matching, and gray deployment.
  4. Strong scalability: The development threshold for gateway plugins is lowered to the level of developing a tRPC filter, allowing for quick expansion of business-specific gateway logic.
  5. Easy enrichment of plugin ecosystem: The development threshold for gateway plugins is low enough to easily enrich the plugin ecosystem.

Background

In the context of cloud-native technology, business gateways have become indispensable. With the gradual adoption of the internal tRPC framework within the company, there are two solutions to meet the demands for business gateways:

1 Modifying an external open-source gateway: This solution allows for the reuse of core functions from an open-source gateway but requires significant adaptation work to fit into the tRPC ecosystem.

2 Building a business gateway within the tRPC ecosystem based on the tRPC framework: It was found that this only requires the development of gateway routing logic.

tRPC-Gateway is a business gateway developed based on solution 2.

Gateway Deployment:

Running Local Demo

See example/README.md

Deployment on with etcd
  1. Create a new service repository and add the main.go file, refer to main.go main.go
  2. Apply for Rainbow configuration and add the router.yaml configuration file, refer to router.yaml
  3. Deploy the service with framework configuration, refer to trpc_go.yaml

Routing Configuration

Modify the router.yaml file to configure the forwarding of your own interfaces. For more details, see Routing Configuration

Gateway Plugin Development

You can extend the functionality of the gateway through plugins. See Gateway Plugin Development for more details.

List of Common Plugins

Forwarding Protocol Support

tRPC-Gateway supports HTTP as the entry protocol and can forward to other protocols. Custom protocols can be implemented by implementing the CliProtocolHandler interface.

Supported forwarding protocols:

  • http -> http
  • http -> trpc
  • http -> grpc
Does it support trpc -> trpc protocol forwarding?

No, it doesn't support trpc -> trpc protocol forwarding because it would require writing separate plugin logic to support both HTTP and trpc protocols, which would increase complexity.

If the caller expects to use the trpc pb client for calling, you can use the http -> trpc forwarding method. There is no difference in the caller's code, except that the caller's protocol can only use http.

How to Contribute

You can fork the project, make modifications, and initiate a merge request (MR). For more details, please consult [email protected]

Documentation

Index

Constants

View Source
const (
	MajorVersion  = 0
	MinorVersion  = 1
	PatchVersion  = 0
	VersionSuffix = "-dev" // -alpha -alpha.1 -beta -rc -rc.1
)

rule of trpc version 1. MAJOR version when you make incompatible API changes; 2. MINOR version when you add functionality in a backwards-compatible manner; 3. PATCH version when you make backwards-compatible bug fixes; 4. Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format; alpha 0.1.0-alpha beta 0.1.0-beta release candidate 0.1.0-rc release 0.1.0

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the version of trpc.

Types

This section is empty.

Directories

Path Synopsis
common
convert
Package convert some parameter conversion utility functions.
Package convert some parameter conversion utility functions.
errs
Package errs API gateway framework error related definitions, related methods
Package errs API gateway framework error related definitions, related methods
gwmsg
Package gwmsg defines gateway message
Package gwmsg defines gateway message
gwmsg/mock
Package mock_gwmsg is a generated GoMock package.
Package mock_gwmsg is a generated GoMock package.
http
Package http contains utility methods related to HTTP.
Package http contains utility methods related to HTTP.
plugin
Package plugin refers to constants and common methods related to gateway plugins.
Package plugin refers to constants and common methods related to gateway plugins.
core
config
Package config provides gateway configuration related functions
Package config provides gateway configuration related functions
config/configmock
Package configmock is a generated GoMock package.
Package configmock is a generated GoMock package.
entity
Package entity defines entities related to route configuration.
Package entity defines entities related to route configuration.
loader/file
Package file provides a router config loader with file.
Package file provides a router config loader with file.
router
Package router Gateway routing module
Package router Gateway routing module
router/mock
Package mock_router is a generated GoMock package.
Package mock_router is a generated GoMock package.
rule
Package rule encapsulates a simple rule matching mechanism for dynamic parameter matching
Package rule encapsulates a simple rule matching mechanism for dynamic parameter matching
service/fhttp/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
service/protocol/http
Package http converts fasthttp requests to net/http requests It refers to the logic of net/http/httputil/reverseproxy.go
Package http converts fasthttp requests to net/http requests It refers to the logic of net/http/httputil/reverseproxy.go
service/protocol/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
loader/etcd Module
example
loader/upstream
example of gateway
example of gateway
pool/objectpool
Package objectpool provides object pool.
Package objectpool provides object pool.
reuseport
Package reuseport provides a function that returns a net.Listener powered by a net.FileListener with a SO_REUSEPORT option set to the socket.
Package reuseport provides a function that returns a net.Listener powered by a net.FileListener with a SO_REUSEPORT option set to the socket.
Package plugin defines gateway plugins.
Package plugin defines gateway plugins.
demo
Package demo is an example of developing a gateway plugin.
Package demo is an example of developing a gateway plugin.
mock
Package mock_plugin is a generated GoMock package.
Package mock_plugin is a generated GoMock package.
accesslog Module
batchrequest Module
cors Module
devenv Module
logreplay Module
mocking Module
redirect Module
routercheck Module
traceid Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL