Skip to content

Commit 011c58c

Browse files
author
Maksim Konovalov
committed
pool: add comments for balancer factory
1 parent c1ef162 commit 011c58c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pool/balancer.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,34 @@ package pool
22

33
import "github.com/tarantool/go-tarantool/v2"
44

5+
// BalancerFactory is an interface for creating a balancing pool of connections.
56
type BalancerFactory interface {
7+
// Create initializes a new BalancingPool with the specified size.
8+
// The size parameter indicates the intended number of connections to manage within the pool.
69
Create(size int) BalancingPool
710
}
811

12+
// BalancingPool represents a connection pool with load balancing.
913
type BalancingPool interface {
14+
// GetConnection returns the connection associated with the specified identifier.
15+
// If no connection with the given identifier is found, it returns nil.
1016
GetConnection(string) *tarantool.Connection
17+
18+
// DeleteConnection removes the connection with the specified identifier from the pool
19+
// and returns the removed connection. If no connection is found, it returns nil.
1120
DeleteConnection(string) *tarantool.Connection
21+
22+
// AddConnection adds a new connection to the pool under the specified identifier.
23+
// If a connection with that identifier already exists, the behavior may depend
24+
// on the implementation (e.g., it may overwrite the existing connection).
1225
AddConnection(id string, conn *tarantool.Connection)
26+
27+
// GetNextConnection returns the next available connection from the pool.
28+
// The implementation may use load balancing algorithms to select the connection.
1329
GetNextConnection() *tarantool.Connection
30+
31+
// GetConnections returns the current map of all connections in the pool,
32+
// where the key is the connection identifier and the value is a pointer to the connection object.
1433
GetConnections() map[string]*tarantool.Connection
1534
}
1635

0 commit comments

Comments
 (0)