grpc

package
v0.4.1-dev1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientWithAuthForward added in v0.3.6

func NewClientWithAuthForward[T any](ctx context.Context, addr string, requireTransportSecurity bool, clientFactory func(cc grpc.ClientConnInterface) T) (*grpc.ClientConn, T, error)

NewClientWithAuthForward creates a new gRPC client which forwards the authentication bearer token received from the client (TLS optional)

func NewClientWithInsecure added in v0.3.6

func NewClientWithInsecure[T any](ctx context.Context, addr string, clientFactory func(cc grpc.ClientConnInterface) T) (*grpc.ClientConn, T, error)

NewClientWithInsecure creates a new gRPC client which connects without TLS

func NewClientWithInsecureAuth added in v0.3.6

func NewClientWithInsecureAuth[T any](ctx context.Context, addr, authToken string, clientFactory func(cc grpc.ClientConnInterface) T) (*grpc.ClientConn, T, error)

NewClientWithInsecureAuth (USE ONLY IF SECURED BY SERVICE MESH OR SIMILAR) creates a new gRPC client which sends the auth token without TLS

func NewForwardedOauthAccess added in v0.3.6

func NewForwardedOauthAccess(requireTransportSecurity bool) credentials.PerRPCCredentials

NewForwardedOauthAccess constructs the PerRPCCredentials which forwards the authorization from header

func NewOauthAccessWithoutTransportSecurity added in v0.3.6

func NewOauthAccessWithoutTransportSecurity(token *oauth2.Token) credentials.PerRPCCredentials

NewOauthAccessWithoutTransportSecurity constructs the PerRPCCredentials using a given token for test purposes where no TLS necessary.

Types

type GrpcConnectionFactory added in v0.3.6

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

func NewGrpcConnectionFactory

func NewGrpcConnectionFactory(url string) *GrpcConnectionFactory

NewGrpcConnectionFactory creates a new factory for gRPC connections.

func NewGrpcConnectionFactoryWithInsecure added in v0.3.6

func NewGrpcConnectionFactoryWithInsecure(url string) *GrpcConnectionFactory

NewGrpcConnectionFactoryWithInsecure creates a new factory for gRPC connections and adds the following dial options: WithInsecure, WithBlock.

func (*GrpcConnectionFactory) Connect added in v0.3.6

func (factory *GrpcConnectionFactory) Connect(ctx context.Context) (*grpc.ClientConn, error)

Connect creates a client connection based on the factory.

func (*GrpcConnectionFactory) ConnectWithTimeout added in v0.3.6

func (factory *GrpcConnectionFactory) ConnectWithTimeout(ctx context.Context, timeout time.Duration) (*grpc.ClientConn, error)

ConnectWithTimeout creates a client connection based on the factory with a given timeout.

func (*GrpcConnectionFactory) WithBlock added in v0.3.6

func (factory *GrpcConnectionFactory) WithBlock() *GrpcConnectionFactory

WithBlock adds a DialOption which makes caller of Dial blocks until the underlying connection is up. Without this, Dial returns immediately and connecting the server happens in background.

func (*GrpcConnectionFactory) WithInsecure added in v0.3.6

func (factory *GrpcConnectionFactory) WithInsecure() *GrpcConnectionFactory

WithInsecure adds a DialOption which disables transport security for this connection. Note that transport security is required unless WithInsecure is set.

func (*GrpcConnectionFactory) WithOSCaTransportCredentials added in v0.3.6

func (factory *GrpcConnectionFactory) WithOSCaTransportCredentials() *GrpcConnectionFactory

WithOSCaTransportCredentials adds a DialOption which configures a connection level security credentials (e.g., TLS/SSL) using the CAs known to the OS.

func (*GrpcConnectionFactory) WithPerRPCCredentials added in v0.3.6

func (factory *GrpcConnectionFactory) WithPerRPCCredentials(creds credentials.PerRPCCredentials) *GrpcConnectionFactory

WithPerRPCCredentials adds a DialOption which sets credentials and places auth state on each outbound RPC.

func (*GrpcConnectionFactory) WithRetry added in v0.3.6

func (factory *GrpcConnectionFactory) WithRetry() *GrpcConnectionFactory

WithRetry adds retrying with exponential backoff using the default retryable codes from grpc_retry.DefaultRetriableCodes.

func (*GrpcConnectionFactory) WithTransportCredentials added in v0.3.6

func (factory *GrpcConnectionFactory) WithTransportCredentials(creds credentials.TransportCredentials) *GrpcConnectionFactory

Connect creates a client connection based on the factory.

type Server

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

Server is the implementation of an API Server

func NewServer

func NewServer(name string, keepAlive bool, opt ...grpc.ServerOption) *Server

NewServer returns a new configured instance of Server

func NewServerWithOpts

func NewServerWithOpts(name string, keepAlive bool, unaryServerInterceptors []grpc.UnaryServerInterceptor, streamServerInterceptors []grpc.StreamServerInterceptor, opt ...grpc.ServerOption) *Server

NewServerWithOpts returns a new configured instance of Server with additional interceptors specified

func (*Server) RegisterService

func (s *Server) RegisterService(f func(grpc.ServiceRegistrar))

RegisterService registers your gRPC service implementation with the server

func (*Server) Serve

func (s *Server) Serve(apiAddr, metricsAddr string) error

Serve starts the api listeners of the Server

func (*Server) ServeFromListener

func (s *Server) ServeFromListener(apiLis net.Listener, metricsLis net.Listener) error

ServeFromListener starts the api listeners of the Server

func (*Server) Shutdown

func (s *Server) Shutdown()

Tell the server to shutdown

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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