grpc

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package grpc defines the helper functions to simplify the gRPC client connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

Dial returns a gRPC connection configured with the given ClientOptions. In this call WithConnectionPoolSize() is ignored! Use DialPool instead.

Types

type ClientOption

type ClientOption interface {
	Apply(*internal.DialSettings)
}

A ClientOption is an option for an API client.

func WithConnectionPoolSize

func WithConnectionPoolSize(poolSize int) ClientOption

WithConnectionPoolSize Returns a ClientOption that sets up Connection Pool Size.

func WithCredentialsJSON

func WithCredentialsJSON(p []byte) ClientOption

WithCredentialsJSON returns a ClientOption that authenticates API calls with the given service account or refresh token JSON credentials. This value is ignored if used WithInsecure. Be sure NOT to have set INDYKITE env variables or use WithIgnoredEnvVariables.

func WithCredentialsLoader

func WithCredentialsLoader(opts ...config.CredentialsLoader) ClientOption

WithCredentialsLoader returns a ClientOption that adds ConfigLoaders.

func WithEndpoint

func WithEndpoint(url string) ClientOption

WithEndpoint returns a ClientOption that overrides the default endpoint.

func WithGRPCConn

func WithGRPCConn(conn *grpc.ClientConn) ClientOption

WithGRPCConn returns a ClientOption that specifies the gRPC client to use as basis of communications. This option may only be used with services that support gRPC.

func WithGRPCDialOption

func WithGRPCDialOption(opt grpc.DialOption) ClientOption

WithGRPCDialOption returns a ClientOption that appends a new grpc.DialOption to an underlying gRPC dial. It does not work with WithGRPCConn.

func WithInsecure

func WithInsecure() ClientOption

WithInsecure returns a ClientOption that sets insecure to true This is intended to be used only in tests!

func WithRetryOptions

func WithRetryOptions(opts ...retry.CallOption) ClientOption

WithRetryOptions returns a ClientOption that sets default retry options.

func WithServiceAccount

func WithServiceAccount() ClientOption

WithServiceAccount returns a ClientOption that requires service account configuration and fails if an application agent credential is loaded.

func WithTelemetryDisabled

func WithTelemetryDisabled() ClientOption

WithTelemetryDisabled returns a ClientOption that disables default telemetry (Open Telemetry) settings on gRPC and HTTP clients.

func WithTelemetryTraceName

func WithTelemetryTraceName(name string) ClientOption

WithTelemetryTraceName returns a ClientOption that sets default tracer name settings on gRPC and HTTP clients. If the name is an empty string then provider uses default name.

func WithTokenSource

func WithTokenSource(s oauth2.TokenSource) ClientOption

WithTokenSource returns a ClientOption that specifies an OAuth2 token source. This value is ignored if used WithInsecure. Be sure NOT to have set INDYKITE env variables or use WithIgnoredEnvVariables.

func WithUserAgent

func WithUserAgent(ua string) ClientOption

WithUserAgent returns a ClientOption that sets the User-Agent.

type ConnPool

type ConnPool interface {
	// Conn returns a ClientConn from the pool.
	//
	// Conn aren't returned to the pool.
	Conn() *grpc.ClientConn

	// Num returns the number of connections in the pool.
	//
	// It will always return the same value.
	Num() int

	// Close closes every ClientConn in the pool.
	//
	// The error returned by Close may be a single error or multiple errors.
	Close() error

	// ClientConnInterface implements grpc.ClientConnInterface to enable it to be used
	// directly with generated proto stubs.
	grpc.ClientConnInterface
}

ConnPool is a pool of grpc.ClientConns.

func DialPool

DialPool returns a connection pool configured with ClientOptions. If grpcConn is specified in ClientOptions, pool size is reset to 1.

Directories

Path Synopsis
Package config implements the standard client configuration file parser.
Package config implements the standard client configuration file parser.
Package internal contains Dial settings and helpers
Package internal contains Dial settings and helpers
Package jwt implements an oauth2.JWTokenSource implementation.
Package jwt implements an oauth2.JWTokenSource implementation.

Jump to

Keyboard shortcuts

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