grpcserver

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig rpc.Config = rpc.Config{
	MaxMessageSize:            rpc.DefaultMaxMessageSize,
	GRPCPort:                  8264,
	GRPCInitialConnWindowSize: 0,
	GRPCInitialWindowSize:     0,
	EnableTracing:             false,
	EnableGRPCPrometheus:      false,
	GRPCKeepAliveEnforcementPolicyPermitWithoutStream: false,
	GRPCCert:                              "",
	GRPCKey:                               "",
	GRPCCA:                                "",
	GRPCAuth:                              "",
	GRPCMaxConnectionAge:                  time.Duration(math.MaxInt64),
	GRPCMaxConnectionAgeGrace:             time.Duration(math.MaxInt64),
	GRPCKeepAliveEnforcementPolicyMinTime: 5 * time.Minute,
}

DefaultConfig - rpc default config

Functions

func FakeAuthStreamInterceptor

func FakeAuthStreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

FakeAuthStreamInterceptor fake interceptor to test plugin

func FakeAuthUnaryInterceptor

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

FakeAuthUnaryInterceptor fake interceptor to test plugin

func GetAuthenticator

func GetAuthenticator(name string) (func([]byte) (Authenticator, error), error)

GetAuthenticator returns an AuthPlugin by name, or log.Fatalf.

func RegisterAuthPlugin

func RegisterAuthPlugin(name string, authPlugin func([]byte) (Authenticator, error)) error

RegisterAuthPlugin registers an implementation of AuthServer.

Types

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context, fullMethod string) (context.Context, error)
}

Authenticator provides an interface to implement auth in Vitess in grpc server

type InterceptorBuilder

type InterceptorBuilder struct {
	StreamServerInterceptor grpc.StreamServerInterceptor
	UnaryStreamInterceptor  grpc.UnaryServerInterceptor
}

InterceptorBuilder chains together multiple ServerInterceptors

func (*InterceptorBuilder) Add

Add is used to add two ServerInterceptors.

func (*InterceptorBuilder) NonEmpty

func (collector *InterceptorBuilder) NonEmpty() bool

NonEmpty check if ServerInterceptor is empty.

type Server

type Server struct {
	*grpc.Server
	// contains filtered or unexported fields
}

Server - rpc server

func NewRPCServer

func NewRPCServer(cfg *rpc.Config) (*Server, error)

NewRPCServer create the gRPC server we will be using. It has to be called after flags are parsed, but before services register themselves.

func (*Server) Close

func (s *Server) Close()

Close - close rpc

func (*Server) Run

func (s *Server) Run() error

Run - run rpc server

type StaticAuthConfigEntry

type StaticAuthConfigEntry struct {
	Username string
	Password string
}

StaticAuthConfigEntry is the container for server side credentials. Current implementation matches the the one from the client but this will change in the future as we hooked this pluging into ACL features.

type StaticAuthPlugin

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

StaticAuthPlugin implements static username/password authentication for grpc. It contains an array of username/passwords that will be authorized to connect to the grpc server.

func (*StaticAuthPlugin) Authenticate

func (sa *StaticAuthPlugin) Authenticate(ctx context.Context, fullMethod string) (context.Context, error)

Authenticate implements AuthPlugin interface. This method will be used inside a middleware in grpc_server to authenticate incoming requests.

type WrappedServerStream

type WrappedServerStream struct {
	grpc.ServerStream
	WrappedContext context.Context
}

WrappedServerStream is based on the service stream wrapper from: https://github.com/grpc-ecosystem/go-grpc-middleware

func WrapServerStream

func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream

WrapServerStream returns a ServerStream that has the ability to overwrite context.

func (*WrappedServerStream) Context

func (w *WrappedServerStream) Context() context.Context

Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()

Jump to

Keyboard shortcuts

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