-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert object sync status events #1360
Conversation
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
…objectsync-status-events
WalkthroughThe updates introduce a new interface, Changes
Sequence Diagram(s)sequenceDiagram
participant Service
participant StatusWatcher
participant UpdateReceiver
participant Context
Service->>UpdateReceiver: SetUpdateReceiver(updateReceiver)
Service->>StatusWatcher: SetUpdateReceiver(updateReceiver)
Service->>UpdateReceiver: indexFileSyncStatus(context.Context, fileObjectId, status)
UpdateReceiver->Context: Create context
UpdateReceiver->>UpdateTree: UpdateTree(context, fileObjectId, status)
UpdateReceiver->>Service: Return status or error
Poem
🐇✨💻 Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
core/syncstatus/objectsyncstatus/mock_UpdateReceiver.go
is excluded by!**/mock_*.go
Files selected for processing (7)
- .mockery.yaml (1 hunks)
- core/syncstatus/filestatus.go (2 hunks)
- core/syncstatus/objectsyncstatus/syncstatus.go (6 hunks)
- core/syncstatus/objectsyncstatus/syncstatus_test.go (2 hunks)
- core/syncstatus/service.go (4 hunks)
- core/syncstatus/updatereceiver.go (1 hunks)
- core/syncstatus/updatereceiver_test.go (1 hunks)
Additional comments not posted (27)
core/syncstatus/service.go (6)
9-9
: Import added:nodeconf
.New import added for
nodeconf
. Ensure that this import is necessary and used appropriately in the file.
11-11
: Import added:config
.New import added for
config
. Ensure that this import is necessary and used appropriately in the file.
13-13
: Import added:event
.New import added for
event
. Ensure that this import is necessary and used appropriately in the file.
34-34
: Field added:updateReceiver
.A new field
updateReceiver
of type*updateReceiver
is added to theservice
struct. Ensure that this field is used and initialized correctly.
62-66
: Initialization ofupdateReceiver
inInit
method.The
updateReceiver
is initialized usingnewUpdateReceiver
with necessary dependencies. Ensure that all dependencies (nodeConfService
,cfg
,eventSender
,objectStore
,nodeStatus
) are correctly provided and initialized.
82-84
: SettingupdateReceiver
inRegisterSpace
method.The
RegisterSpace
method sets theupdateReceiver
forStatusWatcher
and updates thespaceId
of theupdateReceiver
. Ensure that this setting is necessary and correctly implemented.core/syncstatus/updatereceiver.go (8)
1-30
: Introduction ofupdateReceiver
type.A new type
updateReceiver
is introduced with fields foreventSender
,nodeConfService
,nodeConnected
,objectStore
,nodeStatus
, andspaceId
. Ensure that all fields are necessary and used appropriately.
31-47
: ConstructornewUpdateReceiver
.The constructor
newUpdateReceiver
initializes theupdateReceiver
with necessary dependencies. Ensure that all dependencies are correctly provided and initialized.
49-53
: Implementation ofUpdateTree
method.The
UpdateTree
method updates the tree status and sends a notification. Ensure that the method correctly updates the status and handles errors appropriately.
55-64
: Implementation ofgetFileStatus
method.The
getFileStatus
method retrieves the file status from the object store. Ensure that the method correctly retrieves the status and handles errors appropriately.
66-90
: Implementation ofgetObjectSyncStatus
method.The
getObjectSyncStatus
method determines the object sync status based on file status and network compatibility. Ensure that the method correctly determines the status and handles errors appropriately.
92-96
: Implementation ofisNodeConnected
method.The
isNodeConnected
method checks if the node is connected. Ensure that the method correctly checks the node connectivity.
98-102
: Implementation ofUpdateNodeStatus
method.The
UpdateNodeStatus
method updates the node status. Ensure that the method correctly updates the node status.
104-125
: Implementation ofnotify
andsendEvent
methods.The
notify
method sends an event notification using thesendEvent
method. Ensure that the methods correctly send event notifications.core/syncstatus/filestatus.go (2)
4-4
: Import added:context
.New import added for
context
. Ensure that this import is necessary and used appropriately in the file.
55-57
: Update inindexFileSyncStatus
method.The
indexFileSyncStatus
method updates the tree status by callingupdateReceiver.UpdateTree
and handles errors appropriately. Ensure that the method correctly updates the status and handles errors..mockery.yaml (1)
185-189
: Interface added:UpdateReceiver
.A new interface
UpdateReceiver
is added with configurations for directories and packages. Ensure that the interface and configurations are necessary and correctly implemented.core/syncstatus/objectsyncstatus/syncstatus.go (5)
82-85
: LGTM!The addition of the
updateReceiver
field in thesyncStatusService
struct is necessary to support the new functionality introduced by theUpdateReceiver
interface.
133-138
: LGTM!The implementation of the
SetUpdateReceiver
method in thesyncStatusService
struct is correct, with proper locking and unlocking of the mutex.
Line range hint
165-185
: LGTM!The changes to the
update
method are necessary to integrate the new functionality provided by theUpdateReceiver
interface. Proper error handling has been added.
34-35
: LGTM! EnsureUpdateNodeStatus
is implemented correctly.The addition of the
err
return value forUpdateTree
and the new methodUpdateNodeStatus
are good practices for error handling and functionality expansion.
55-55
: LGTM! EnsureSetUpdateReceiver
is implemented correctly.The addition of the
SetUpdateReceiver
method allows for dynamic updating of theupdateReceiver
, which is a good practice for flexibility.Verification successful
Verified Implementation of
SetUpdateReceiver
The method
SetUpdateReceiver
is implemented within thesyncStatusService
struct and is referenced in the codebase, confirming the review comment's approval.
core/syncstatus/objectsyncstatus/syncstatus.go
: Implementation ofSetUpdateReceiver
.core/syncstatus/service.go
: Reference toSetUpdateReceiver
.core/syncstatus/objectsyncstatus/syncstatus_test.go
: Reference toSetUpdateReceiver
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `SetUpdateReceiver`. # Test: Search for the implementation of `SetUpdateReceiver`. Expect: At least one implementation. ast-grep --lang go --pattern $'func ($_ StatusWatcher).SetUpdateReceiver($_ UpdateReceiver) $_ { $$$ }'Length of output: 104
Script:
#!/bin/bash # Description: Re-verify the implementation of `SetUpdateReceiver` with a broader search pattern. # Test: Search for the implementation of `SetUpdateReceiver` in any struct or interface. Expect: At least one implementation. ast-grep --lang go --pattern $'func ($_).SetUpdateReceiver($_ UpdateReceiver) $_ { $$$ }'Length of output: 90
Script:
#!/bin/bash # Description: Verify if `SetUpdateReceiver` is referenced anywhere in the codebase. # Test: Search for any references to `SetUpdateReceiver`. Expect: At least one reference. rg 'SetUpdateReceiver'Length of output: 388
core/syncstatus/updatereceiver_test.go (4)
1-20
: LGTM!The imports are necessary for the new test cases introduced in this file.
22-219
: LGTM!The
TestUpdateReceiver_UpdateTree
function is comprehensive and covers various scenarios for updating the tree status. Each test case is well-structured with given, when, and then sections.
222-237
: LGTM!The
newFixture
function is necessary to set up the test environment for theupdateReceiver
tests.
239-244
: LGTM!The
fixture
struct is necessary to organize the test components for theupdateReceiver
tests.core/syncstatus/objectsyncstatus/syncstatus_test.go (1)
Line range hint
231-246
: LGTM!The changes to the
TestSyncStatusService_update
function are necessary to test the new functionality introduced by theUpdateReceiver
interface.
Coverage provided by https://github.com/seriousben/go-patch-cover-action |
No description provided.