Documentation
¶
Index ¶
- type Connection
- type ConnectionPool
- func (cp *ConnectionPool) Delete(key string)
- func (cp *ConnectionPool) GetByNodeID(driverName, nodeID string) (map[string]*Connection, error)
- func (cp *ConnectionPool) GetLeaderByDriver(ctx context.Context, reconciler client.Client, driverName string) (*Connection, error)
- func (cp *ConnectionPool) Put(key string, conn *Connection)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
sync.Mutex
Client *grpc.ClientConn
Capabilities []*identity.Capability
Namespace string
Name string
NodeID string
DriverName string
Timeout time.Duration
// contains filtered or unexported fields
}
Connection struct consists of to NodeID, DriverName, Capabilities for the controller to pick sidecar connection and grpc Client to connect to the sidecar.
func NewConnection ¶
func NewConnection(ctx context.Context, endpoint, nodeID, driverName, namespace, podName string, enableAuth bool) (*Connection, error)
NewConnection establishes connection with sidecar, fetches capability and returns Connection object filled with required information.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close tears down the gRPC connection and terminates the goroutines monitoring the idle timeout by calling cancelIdle()
func (*Connection) Connect ¶ added in v0.13.0
func (c *Connection) Connect() error
Connect creates a new grpc.ClientConn object and sets it as the client property on Connection struct. If a connection is already connected, it is reused as is. It also spawns a go routine to tear down the connection if it has been idling for a specified threshold.
In cases where a new connection is created from the scratch Connect also calls fetchCapabilities on the connection object.
func (*Connection) HasControllerService ¶ added in v0.8.0
func (c *Connection) HasControllerService() bool
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool consists of map of Connection objects and methods Put, Get & Delete which operates with required rw locks to ensure consistency. CSIAddonsNode controller will use Put and Delete methods whereas other controllers will make use of Get to choose and connect to sidecar.
func NewConnectionPool ¶
func NewConnectionPool() *ConnectionPool
NewConntionPool initializes and returns ConnectionPool object.
func (*ConnectionPool) Delete ¶
func (cp *ConnectionPool) Delete(key string)
Delete deletes connection object corresponding to given key.
func (*ConnectionPool) GetByNodeID ¶
func (cp *ConnectionPool) GetByNodeID(driverName, nodeID string) (map[string]*Connection, error)
GetByNodeID returns map of connections, filtered with given driverName and optional nodeID.
func (*ConnectionPool) GetLeaderByDriver ¶ added in v0.8.0
func (cp *ConnectionPool) GetLeaderByDriver(ctx context.Context, reconciler client.Client, driverName string) (*Connection, error)
GetLeaderByDriver finds the holder of the lease for the driver, and returns the connection to that particular CSI-Addons sidecar.
func (*ConnectionPool) Put ¶
func (cp *ConnectionPool) Put(key string, conn *Connection)
Put adds connection object into map.