connection

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 10 Imported by: 83

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(address string, metricsManager metrics.CSIMetricsManager, options ...Option) (*grpc.ClientConn, error)

Connect opens insecure gRPC connection to a CSI driver. Address must be either absolute path to UNIX domain socket file or have format '<protocol>://', following gRPC name resolution mechanism at https://github.com/grpc/grpc/blob/master/doc/naming.md.

The function tries to connect indefinitely every second until it connects. The function automatically disables TLS and adds interceptor for logging of all gRPC messages at level 5.

For a connection to a Unix Domain socket, the behavior after loosing the connection is configurable. The default is to log the connection loss and reestablish a connection. Applications which need to know about a connection loss can be notified by passing a callback with OnConnectionLoss and in that callback can decide what to do: - exit the application with os.Exit - invalidate cached information - disable the reconnect, which will cause all gRPC method calls to fail with status.Unavailable

For other connections, the default behavior from gRPC is used and loss of connection is not detected reliably.

func ExitOnConnectionLoss added in v0.3.1

func ExitOnConnectionLoss() func() bool

ExitOnConnectionLoss returns callback for OnConnectionLoss() that writes an error to /dev/termination-log and exits.

func LogGRPC

func LogGRPC(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

LogGRPC is gPRC unary interceptor for logging of CSI messages at level 5. It removes any secrets from the message.

Types

type Option

type Option func(o *options)

Option is the type of all optional parameters for Connect.

func OnConnectionLoss

func OnConnectionLoss(reconnect func() bool) Option

OnConnectionLoss registers a callback that will be invoked when the connection got lost. If that callback returns true, the connection is reestablished. Otherwise the connection is left as it is and all future gRPC calls using it will fail with status.Unavailable.

Jump to

Keyboard shortcuts

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