rpc

package
v1.25.0-113.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultServiceConfig is a default gRPC connection service config which enables DNS round robin between IPs.
	// To use DNS resolver, a "dns:///" prefix should be applied to the hostPort.
	// https://github.com/grpc/grpc/blob/master/doc/naming.md
	DefaultServiceConfig = `{"loadBalancingConfig": [{"round_robin":{}}]}`

	// MaxBackoffDelay is a maximum interval between reconnect attempts.
	MaxBackoffDelay = 10 * time.Second

	// MaxHTTPAPIRequestBytes is the maximum number of bytes an HTTP API request
	// can have. This is currently set to the max gRPC request size.
	MaxHTTPAPIRequestBytes = 4 * 1024 * 1024

	// MaxHTTPAPIRequestBytes is the maximum number of bytes a Nexus HTTP API request can have. Because the body is
	// read into a Payload object, this is currently set to the max Payload size. Content headers are transformed to
	// Payload metadata and contribute to the Payload size as well. A separate limit is enforced on top of this.
	MaxNexusAPIRequestBodyBytes = 2 * 1024 * 1024

	// ResourceExhaustedCauseHeader will be added to rpc response if request returns ResourceExhausted error.
	// Value of this header will be ResourceExhaustedCause.
	ResourceExhaustedCauseHeader = "X-Resource-Exhausted-Cause"

	// ResourceExhaustedScopeHeader will be added to rpc response if request returns ResourceExhausted error.
	// Value of this header will be the scope of exhausted resource.
	ResourceExhaustedScopeHeader = "X-Resource-Exhausted-Scope"
)

Variables

This section is empty.

Functions

func CopyContextValues added in v1.17.2

func CopyContextValues(dst context.Context, src context.Context) context.Context

CopyContextValues copies values in source Context to destination Context.

func Dial

func Dial(hostName string, tlsConfig *tls.Config, logger log.Logger, interceptors ...grpc.UnaryClientInterceptor) (*grpc.ClientConn, error)

Dial creates a client connection to the given target with default options. The hostName syntax is defined in https://github.com/grpc/grpc/blob/master/doc/naming.md. e.g. to use dns resolver, a "dns:///" prefix should be applied to the target.

func FrontendErrorInterceptor added in v1.24.0

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

func NewContextFromParentWithTimeoutAndVersionHeaders added in v1.17.2

func NewContextFromParentWithTimeoutAndVersionHeaders(parentCtx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

NewContextFromParentWithTimeoutAndVersionHeaders creates context from parent context with timeout and version headers.

func NewContextWithTimeoutAndVersionHeaders added in v1.17.2

func NewContextWithTimeoutAndVersionHeaders(timeout time.Duration) (context.Context, context.CancelFunc)

NewContextWithTimeoutAndVersionHeaders creates context with timeout and version headers.

func NewServiceErrorInterceptor added in v1.24.0

func NewServiceErrorInterceptor(
	logger log.Logger,
) grpc.UnaryServerInterceptor

func ResetContextTimeout added in v1.21.0

func ResetContextTimeout(ctx context.Context, newTimeout time.Duration) (context.Context, context.CancelFunc)

ResetContextTimeout creates new context with specified timeout and copies values from source Context.

Types

type RPCFactory

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

RPCFactory is an implementation of common.RPCFactory interface

func NewFactory

func NewFactory(
	cfg *config.RPC,
	sName primitives.ServiceName,
	logger log.Logger,
	tlsProvider encryption.TLSConfigProvider,
	frontendURL string,
	frontendTLSConfig *tls.Config,
	clientInterceptors []grpc.UnaryClientInterceptor,
) *RPCFactory

NewFactory builds a new RPCFactory conforming to the underlying configuration

func (*RPCFactory) CreateInternodeGRPCConnection

func (d *RPCFactory) CreateInternodeGRPCConnection(hostName string) *grpc.ClientConn

CreateInternodeGRPCConnection creates connection for gRPC calls

func (*RPCFactory) CreateLocalFrontendGRPCConnection added in v1.18.0

func (d *RPCFactory) CreateLocalFrontendGRPCConnection() *grpc.ClientConn

CreateLocalFrontendGRPCConnection creates connection for internal frontend calls

func (*RPCFactory) CreateRemoteFrontendGRPCConnection added in v1.18.0

func (d *RPCFactory) CreateRemoteFrontendGRPCConnection(rpcAddress string) *grpc.ClientConn

CreateRemoteFrontendGRPCConnection creates connection for gRPC calls

func (*RPCFactory) GetFrontendClientTlsConfig

func (d *RPCFactory) GetFrontendClientTlsConfig() (*tls.Config, error)

func (*RPCFactory) GetFrontendGRPCServerOptions

func (d *RPCFactory) GetFrontendGRPCServerOptions() ([]grpc.ServerOption, error)

func (*RPCFactory) GetGRPCListener

func (d *RPCFactory) GetGRPCListener() net.Listener

GetGRPCListener returns cached dispatcher for gRPC inbound or creates one

func (*RPCFactory) GetInternodeClientTlsConfig

func (d *RPCFactory) GetInternodeClientTlsConfig() (*tls.Config, error)

func (*RPCFactory) GetInternodeGRPCServerOptions

func (d *RPCFactory) GetInternodeGRPCServerOptions() ([]grpc.ServerOption, error)

func (*RPCFactory) GetRemoteClusterClientConfig added in v1.15.1

func (d *RPCFactory) GetRemoteClusterClientConfig(hostname string) (*tls.Config, error)

func (*RPCFactory) GetTLSConfigProvider added in v1.5.7

func (d *RPCFactory) GetTLSConfigProvider() encryption.TLSConfigProvider

type RequestIssues added in v1.24.0

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

RequestIssues is a collection of request validation issues for an RPC. The zero value is valid to use.

func (*RequestIssues) Append added in v1.24.0

func (ri *RequestIssues) Append(issue string)

Append an issue to the set.

func (*RequestIssues) Appendf added in v1.24.0

func (ri *RequestIssues) Appendf(format string, args ...interface{})

Appendf appends a formatted issue to the set.

func (*RequestIssues) GetError added in v1.24.0

func (ri *RequestIssues) GetError() error

GetError returns a gRPC INVALID_ARGUMENT error representing the issues in the set or nil if there are no issues.

Directories

Path Synopsis
Package interceptor is a generated GoMock package.
Package interceptor is a generated GoMock package.

Jump to

Keyboard shortcuts

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