Documentation
¶
Index ¶
- func Connect(address string, options ...Option) (*grpc.ClientConn, error)
- func ExitOnConnectionLoss() func() bool
- func GetDriverName(ctx context.Context, conn *grpc.ClientConn) (string, error)
- func LogGRPC(ctx context.Context, method string, req, reply interface{}, ...) error
- func Probe(ctx context.Context, conn *grpc.ClientConn) (ready bool, err error)
- func ProbeForever(conn *grpc.ClientConn, singleProbeTimeout time.Duration) error
- type ControllerCapabilitySet
- type Option
- type PluginCapabilitySet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(address string, 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 GetDriverName ¶ added in v0.3.1
GetDriverName returns name of CSI driver.
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 Probe ¶ added in v0.3.1
Probe calls driver Probe() just once and returns its result without any processing.
func ProbeForever ¶ added in v0.3.1
func ProbeForever(conn *grpc.ClientConn, singleProbeTimeout time.Duration) error
ProbeForever calls Probe() of a CSI driver and waits until the driver becomes ready. Any error other than timeout is returned.
Types ¶
type ControllerCapabilitySet ¶ added in v0.3.1
type ControllerCapabilitySet map[csi.ControllerServiceCapability_RPC_Type]bool
ControllerCapabilitySet is set of CSI controller capabilities. Only supported capabilities are in the map.
func GetControllerCapabilities ¶ added in v0.3.1
func GetControllerCapabilities(ctx context.Context, conn *grpc.ClientConn) (ControllerCapabilitySet, error)
GetControllerCapabilities returns set of supported controller capabilities of CSI driver.
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.
type PluginCapabilitySet ¶ added in v0.3.1
type PluginCapabilitySet map[csi.PluginCapability_Service_Type]bool
PluginCapabilitySet is set of CSI plugin capabilities. Only supported capabilities are in the map.
func GetPluginCapabilities ¶ added in v0.3.1
func GetPluginCapabilities(ctx context.Context, conn *grpc.ClientConn) (PluginCapabilitySet, error)
GetPluginCapabilities returns set of supported capabilities of CSI driver.