Skip to content

Commit

Permalink
Remove some dead pool code (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denchick authored Nov 11, 2024
1 parent f948758 commit da4f36f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 233 deletions.
136 changes: 24 additions & 112 deletions pkg/mock/pool/mock_pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions pkg/pool/conn_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ func (r *ConnectionKepperData) RouterName() string {
return r.Router
}

// List returns a slice of shard.Shard objects.
// It is used to retrieve all the shards stored in the connection keeper.
// Returns an empty slice if no shards are found.
//
// Returns:
// - []shard.Shard: The list of shards stored in the ConnectionKepperData.
func (r *ConnectionKepperData) List() []shard.Shard {
return nil
}

// Rule returns a new instance of BackendRule based on the current ConnectionKepperData.
// It copies the DB and Usr fields from the ConnectionKepperData and returns the new BackendRule.
// The returned BackendRule is not a reference to the original ConnectionKepperData fields.
Expand Down
9 changes: 0 additions & 9 deletions pkg/pool/conn_keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ func TestCoordConnectionKepperRule(t *testing.T) {
assert.Equal("usr", br.Usr)
}

// TestCoordConnectionKepperList is a unit test function that tests the List method of the ConnectionKepperData struct.
func TestCoordConnectionKepperList(t *testing.T) {
assert := assert.New(t)

k := pool.ConnectionKepperData{}

assert.Nil(k.List())
}

// TestCoordConnectionKepperHostname is a unit test function that tests the Hostname method of the ConnectionKepperData struct.
// It asserts that the Hostname method returns the expected hostname value.
func TestCoordConnectionKepperHostname(t *testing.T) {
Expand Down
32 changes: 4 additions & 28 deletions pkg/pool/dbpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,13 @@ func (s *InstancePoolImpl) Connection(
}
}

// InitRule initializes the backend rule in the instance pool.
// It takes a pointer to a BackendRule as a parameter and returns an error.
// SetRule initializes the backend rule in the instance pool.
// It takes a pointer to a BackendRule as a parameter and saves it
//
// Parameters:
// - rule: A pointer to a BackendRule representing the backend rule to be initialized.
//
// Returns:
// - error: An error if there is an error initializing the backend rule, nil otherwise.
func (s *InstancePoolImpl) InitRule(rule *config.BackendRule) error {
return s.pool.InitRule(rule)
func (s *InstancePoolImpl) SetRule(rule *config.BackendRule) {
s.pool.SetRule(rule)
}

// ShardMapping returns the shard mapping of the instance pool.
Expand All @@ -320,15 +317,6 @@ func (s *InstancePoolImpl) ShardMapping() map[string]*config.Shard {
return s.shardMapping
}

// List returns a list of shards in the instance pool.
//
// Returns:
// - []shard.Shard: A list of shards in the instance pool.
func (s *InstancePoolImpl) List() []shard.Shard {
/* mutex? */
return s.pool.List()
}

// ForEach iterates over each shard in the instance pool and calls the provided callback function.
// It returns an error if the callback function returns an error.
//
Expand Down Expand Up @@ -382,18 +370,6 @@ func (s *InstancePoolImpl) ForEachPool(cb func(pool Pool) error) error {
return s.pool.ForEachPool(cb)
}

// Cut removes a shard from the instance pool based on the provided host.
// It returns the removed shard.
//
// Parameters:
// - host: The host of the shard to be removed.
//
// Returns:
// - []shard.Shard: The removed shard.
func (s *InstancePoolImpl) Cut(host string) []shard.Shard {
return s.pool.Cut(host)
}

// Discard removes a shard from the instance pool.
// It returns an error if the removal fails.
//
Expand Down
5 changes: 1 addition & 4 deletions pkg/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type ConnectionKepper interface {
Hostname() string
RouterName() string

List() []shard.Shard

Rule() *config.BackendRule
}

Expand All @@ -47,8 +45,7 @@ type MultiShardPool interface {

Connection(clid uint, shardKey kr.ShardKey, host string) (shard.Shard, error)

InitRule(rule *config.BackendRule) error
Cut(host string) []shard.Shard
SetRule(rule *config.BackendRule)
}

type PoolIterator interface {
Expand Down
Loading

0 comments on commit da4f36f

Please sign in to comment.