dialer

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package dialer provides a caching gRPC dialer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextResolver

func ContextResolver(ctx context.Context) *net.Resolver

ContextResolver returns a Resolver. It may be nil if the value was never set.

func ContextWithDialer

func ContextWithDialer(ctx context.Context, d Dialer) context.Context

ContextWithDialer attaches a Dialer to the given context.

func ContextWithResolver

func ContextWithResolver(ctx context.Context, r *net.Resolver) context.Context

ContextWithResolver attaches a Resolver to the given context.

Types

type ClientConn

type ClientConn interface {
	grpc.ClientConnInterface
	Close() error
}

A ClientConn is a wrapper around the gRPC client connection interface but ensures there is a way to close the connection.

func DialDirectGRPC

func DialDirectGRPC(ctx context.Context, address string, insecure bool) (ClientConn, error)

DialDirectGRPC dials a gRPC server directly.

type Dialer

type Dialer interface {
	// Dial makes a connection to the given target with the supplied options.
	Dial(ctx context.Context, target string, opts ...grpc.DialOption) (ClientConn, error)

	// Close ensures all connections made are cleanly closed.
	Close() error
}

A Dialer is responsible for making connections to gRPC endpoints.

func ContextDialer

func ContextDialer(ctx context.Context) Dialer

ContextDialer returns a Dialer. It may be nil if the value was never set.

func NewCachedDialer

func NewCachedDialer() Dialer

NewCachedDialer returns a Dialer that returns the same connection if it already has been established at a particular target (regardless of the options used).

type RefCountedConnWrapper

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

RefCountedConnWrapper wraps a ClientConn to be reference counted.

func NewRefCountedConnWrapper

func NewRefCountedConnWrapper(conn ClientConn, onUnref func()) *RefCountedConnWrapper

NewRefCountedConnWrapper wraps the given connection to be able to be reference counted.

func (*RefCountedConnWrapper) Ref

Ref returns a new reference to the underlying ClientConn.

type ReffedConn

type ReffedConn struct {
	ClientConn
	// contains filtered or unexported fields
}

A ReffedConn reference counts a ClieentConn and closes it on the last dereference.

func (*ReffedConn) Close

func (rc *ReffedConn) Close() error

Close will deref the reference and if it is the last to do so, will close the underlying connection.

Jump to

Keyboard shortcuts

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