grpc

package
v0.0.0-...-6367170 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentType is a grpc content-type
	ContentType = "application/grpc"
)

Variables

View Source
var KeepaliveOption = grpc.KeepaliveParams(keepalive.ServerParameters{
	MaxConnectionIdle: 5 * time.Minute,
})

KeepaliveOption represents a keep alive option For more information have a look:

https://stackoverflow.com/questions/52993259/problem-with-grpc-setup-getting-an-intermittent-rpc-unavailable-error

Match matches the request

Functions

func CookieFromIncomingContext

func CookieFromIncomingContext(ctx context.Context, name string) (*http.Cookie, error)

CookieFromIncomingContext returns the cookie

func GetString

func GetString(value *string) *wrapperspb.StringValue

GetString converts to a string wrapper from a string pointer

func SetCookie

func SetCookie(ctx context.Context, cookie *http.Cookie) error

SetCookie adds a Set-Cookie header to the provided server transport context. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.

func SetStatusCode

func SetStatusCode(ctx context.Context, code int)

SetStatusCode sets the status code

func ToString

func ToString(value *wrapperspb.StringValue) *string

ToString convert to a string pointer from wrapper

Types

type ChainInterceptor

type ChainInterceptor []Interceptor

ChainInterceptor creates a single interceptor out of a chain of many interceptors.

Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three, and three will see context changes of one and two.

func (ChainInterceptor) Stream

func (ch ChainInterceptor) Stream(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

Stream creates a single stream interceptor out of a chain of many interceptors.

func (ChainInterceptor) Unary

func (ch ChainInterceptor) Unary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

Unary creates a single unary interceptor out of a chain of many interceptors.

type Gateway

type Gateway struct {
	Server  *grpc.Server
	Options []grpc.ServerOption
}

Gateway represents a grpc server

func NewGateway

func NewGateway(opts ...GatewayOption) *Gateway

NewGateway creates a new grpc server

func (*Gateway) Serve

func (gateway *Gateway) Serve(mux cmux.CMux) error

Serve serves the mux

func (*Gateway) Shutdown

func (gateway *Gateway) Shutdown(ctx context.Context) error

Shutdown shutdowns the server

type GatewayOption

type GatewayOption interface {
	Apply(*Gateway)
}

GatewayOption represents a gateway option

func WithChain

func WithChain(chain ChainInterceptor) GatewayOption

WithChain sets the interceptor chain

func WithDefault

func WithDefault() GatewayOption

WithDefault sets the default option

type GatewayOptionFunc

type GatewayOptionFunc func(*Gateway)

GatewayOptionFunc represnts a gateway option func

func (GatewayOptionFunc) Apply

func (fn GatewayOptionFunc) Apply(gw *Gateway)

Apply the option

type Interceptor

type Interceptor interface {
	Unary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
	Stream(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
}

Interceptor represents a grpc interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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