Documentation
¶
Index ¶
- func Connect(address string, metricsManager metrics.CSIMetricsManager, options ...Option) (*grpc.ClientConn, error)
- func ExitOnConnectionLoss() func() bool
- func LogGRPC(ctx context.Context, method string, req, reply interface{}, ...) error
- func SetMaxGRPCLogLength(characterCount int)
- type AdditionalInfo
- type AdditionalInfoKeyType
- type ExtendedCSIMetricsManager
- type Option
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 for 30 seconds, and returns an error if no connection has been established at that point. 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.
func SetMaxGRPCLogLength ¶ added in v0.13.0
func SetMaxGRPCLogLength(characterCount int)
SetMaxGRPCLogLength set the maximum character count for GRPC logging. If characterCount is set to anything smaller than or equal to 0 then there's no limit on log length. The default log length limit is unlimited.
Types ¶
type AdditionalInfo ¶ added in v0.9.1
type AdditionalInfo struct {
Migrated string
}
type AdditionalInfoKeyType ¶ added in v0.9.1
type AdditionalInfoKeyType struct{}
var AdditionalInfoKey AdditionalInfoKeyType
type ExtendedCSIMetricsManager ¶ added in v0.8.0
type ExtendedCSIMetricsManager struct {
metrics.CSIMetricsManager
}
func (ExtendedCSIMetricsManager) RecordMetricsClientInterceptor ¶ added in v0.8.0
func (cmm ExtendedCSIMetricsManager) RecordMetricsClientInterceptor( ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
RecordMetricsClientInterceptor is a gPRC unary interceptor for recording metrics for CSI operations in a gRPC client.
func (ExtendedCSIMetricsManager) RecordMetricsServerInterceptor ¶ added in v0.8.0
func (cmm ExtendedCSIMetricsManager) RecordMetricsServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
RecordMetricsServerInterceptor is a gPRC unary interceptor for recording metrics for CSI operations in a gRCP server.
type Option ¶
type Option func(o *options)
Option is the type of all optional parameters for Connect.
func OnConnectionLoss ¶
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.