Refactor 'Pool' #316

Open
achuprov wants to merge 4 commits from achuprov/frostfs-sdk-go:feat/refactorPool into master
Member

Close #300

This PR splits the functionality of Pool into the following components:

Pool: Provides the external interface for interaction.
connectionManager: Implements the internal functionality for managing clients.
healthCheck: Handles client health monitoring.

Close #300 This PR splits the functionality of `Pool` into the following components: `Pool`: Provides the external interface for interaction. `connectionManager`: Implements the internal functionality for managing clients. `healthCheck`: Handles client health monitoring.
achuprov added 4 commits 2024-12-18 16:19:02 +00:00
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
[#300] pool: Move 'connectionManager' to separate file
All checks were successful
DCO / DCO (pull_request) Successful in 1m18s
Tests and linters / Tests (pull_request) Successful in 3m1s
Tests and linters / Lint (pull_request) Successful in 4m54s
8cce85337b
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
achuprov requested review from storage-core-committers 2024-12-18 16:19:02 +00:00
achuprov requested review from storage-core-developers 2024-12-18 16:19:02 +00:00
achuprov requested review from storage-services-committers 2024-12-18 16:19:02 +00:00
achuprov requested review from storage-services-developers 2024-12-18 16:19:02 +00:00
nzinkevich reviewed 2024-12-23 07:08:34 +00:00
@ -0,0 +12,4 @@
"sync/atomic"
"time"
sdkClient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
Member

nitpick: consider remove uppercase from sdkClient in all files

nitpick: consider remove uppercase from `sdkClient` in all files
@ -1967,3 +1948,3 @@
)
// NewPool creates connection pool using parameters.
// NewPool creates cnnectionManager using parameters.
Member

Typo. Overall I would change comment a bit, e.g. NewPool inits a connectionManager and returns a new Pool instance. Same for newConnectionManager.

Typo. Overall I would change comment a bit, e.g. `NewPool inits a connectionManager and returns a new Pool instance`. Same for `newConnectionManager`.
Owner

It NewPool creates connectionManager, what does newConnectionManager do?

It `NewPool` creates `connectionManager`, what does `newConnectionManager` do?
nzinkevich reviewed 2024-12-23 07:26:38 +00:00
@ -2688,19 +2190,19 @@ func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (ResGetObject, e
//
// Main return value MUST NOT be processed on an erroneous return.
Member

question: Are these comments (here and in other methods) necessary? I believe it's clear that we should not process the result if an error occurs

question: Are these comments (here and in other methods) necessary? I believe it's clear that we should not process the result if an error occurs
achuprov was assigned by dkirillov 2024-12-23 13:25:08 +00:00
Member

In general, LGTM but I have feeling that these entities (Pool, connectionManager and healthchek) are still tight coupled, know a lot about each other (and share responsibility).

As I understand the main idea is getting from connection manager ready client to use. I would expect we form some parameters (prmContext is just fine) and invoke method (initCallContext is also just fine) to get client.
But

I suggest we should make all these struct more loosely coupled. To make it easier to understand responsibility we can place (maybe just during development) each struct into separate package and work with it know nothing about inner struct and just using exported methods

In general, LGTM but I have feeling that these entities (`Pool`, `connectionManager` and `healthchek`) are still tight coupled, know a lot about each other (and share responsibility). * `healthcheck` struct knows about buffers, node params https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/healthcheck.go#L23 though it just runs `callback` by ticker https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/healthcheck.go#L41-L43 * `Pool` struct knows a lot about `connectionManager`. Let's look at `PutObject` https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2054 As I understand the main idea is getting from connection manager ready client to use. I would expect we form some parameters ([prmContext](https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2057) is just fine) and invoke method ([initCallContext](https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2066) is also just fine) to get client. But * we get key from manager (we know that it has key) https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2062 * explicitly open default session (we know that it has such method) https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2072 * we explicitly use cache (unexported field) from `manager` https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2079 * we use very specific error handler from `manager` https://git.frostfs.info/achuprov/frostfs-sdk-go/src/commit/8cce85337b157c0fbafa08ef5e0650f984da0817/pool/pool.go#L2087 I suggest we should make all these struct more loosely coupled. To make it easier to understand responsibility we can place (maybe just during development) each struct into separate package and work with it know nothing about inner struct and just using exported methods
All checks were successful
DCO / DCO (pull_request) Successful in 1m18s
Required
Details
Tests and linters / Tests (pull_request) Successful in 3m1s
Required
Details
Tests and linters / Lint (pull_request) Successful in 4m54s
Required
Details
This pull request doesn't have enough approvals yet. 0 of 2 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u feat/refactorPool:achuprov-feat/refactorPool
git checkout achuprov-feat/refactorPool
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-committers
TrueCloudLab/storage-core-developers
TrueCloudLab/storage-services-committers
TrueCloudLab/storage-services-developers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-sdk-go#316
No description provided.