router

package
v0.2.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package router defines gRPC proxy helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractContext

func ExtractContext(ctx context.Context) *common.Context

ExtractContext reads cluster context from the supplied metadata.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend implements a backend (proxying one2one).

func NewBackend

func NewBackend(name string, conn *grpc.ClientConn) *Backend

NewBackend builds new backend.

func (*Backend) AppendInfo

func (l *Backend) AppendInfo(streaming bool, resp []byte) ([]byte, error)

AppendInfo is called to enhance response from the backend with additional data.

func (*Backend) BuildError

func (l *Backend) BuildError(streaming bool, err error) ([]byte, error)

BuildError is called to convert error from upstream into response field.

func (*Backend) GetConnection

func (l *Backend) GetConnection(ctx context.Context) (context.Context, *grpc.ClientConn, error)

GetConnection returns a grpc connection to the backend.

func (*Backend) String

func (l *Backend) String() string

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router wraps grpc-proxy StreamDirector.

func NewRouter

func NewRouter(local proxy.Backend) *Router

NewRouter builds new Router.

func (*Router) Director

func (r *Router) Director(ctx context.Context, fullMethodName string) (proxy.Mode, []proxy.Backend, error)

Director implements proxy.StreamDirector function.

func (*Router) Register

func (r *Router) Register(srv *grpc.Server)

Register is no-op to implement factory.Registrator interface.

Actual proxy handler is installed via grpc.UnknownServiceHandler option.

Jump to

Keyboard shortcuts

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