Skip to content
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

Merged
merged 5 commits into from
Jul 2, 2024

Conversation

AnastasiaShemyakinskaya
Copy link
Member

No description provided.

Copy link

coderabbitai bot commented Jul 2, 2024

Walkthrough

The updates introduce a new interface, UpdateReceiver, to enhance the sync status functionality by adding configuration options and methods for updating tree statuses and handling node statuses. Modifications span across various files, including service implementations, tests, and configurations, to integrate the UpdateReceiver functionalities, handle errors, and set up necessary updates, making the syncing process more robust and reliable.

Changes

File Path Change Summary
.mockery.yaml Added UpdateReceiver interface configuration.
core/syncstatus/filestatus.go Updated indexFileSyncStatus function with new updateReceiver.UpdateTree method call.
core/syncstatus/.../syncstatus.go Modified UpdateTree method, added UpdateNodeStatus, and set up SetUpdateReceiver method.
core/syncstatus/.../syncstatus_test.go Added tests for updateReceiver methods in TestSyncStatusService_update.
core/syncstatus/service.go Introduced new imports and added updateReceiver field, integrated in methods.
core/syncstatus/updatereceiver.go Introduced a new updateReceiver struct with several status update methods.
core/syncstatus/updatereceiver_test.go Added comprehensive tests for updateReceiver functionalities with various scenarios.

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
Loading

Poem

In a world of code so sleek and bright,
UpdateReceiver took its flight,
With syncing trees and nodes alike,
Errors handled with delight.
Oh, how the bytes dance in cheer,
As the rabbit’s changes draw near!

🐇✨💻


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Copy link

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between e2c084a and 0d3c032.

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 the service struct. Ensure that this field is used and initialized correctly.


62-66: Initialization of updateReceiver in Init method.

The updateReceiver is initialized using newUpdateReceiver with necessary dependencies. Ensure that all dependencies (nodeConfService, cfg, eventSender, objectStore, nodeStatus) are correctly provided and initialized.


82-84: Setting updateReceiver in RegisterSpace method.

The RegisterSpace method sets the updateReceiver for StatusWatcher and updates the spaceId of the updateReceiver. Ensure that this setting is necessary and correctly implemented.

core/syncstatus/updatereceiver.go (8)

1-30: Introduction of updateReceiver type.

A new type updateReceiver is introduced with fields for eventSender, nodeConfService, nodeConnected, objectStore, nodeStatus, and spaceId. Ensure that all fields are necessary and used appropriately.


31-47: Constructor newUpdateReceiver.

The constructor newUpdateReceiver initializes the updateReceiver with necessary dependencies. Ensure that all dependencies are correctly provided and initialized.


49-53: Implementation of UpdateTree 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 of getFileStatus 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 of getObjectSyncStatus 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 of isNodeConnected method.

The isNodeConnected method checks if the node is connected. Ensure that the method correctly checks the node connectivity.


98-102: Implementation of UpdateNodeStatus method.

The UpdateNodeStatus method updates the node status. Ensure that the method correctly updates the node status.


104-125: Implementation of notify and sendEvent methods.

The notify method sends an event notification using the sendEvent 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 in indexFileSyncStatus method.

The indexFileSyncStatus method updates the tree status by calling updateReceiver.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 the syncStatusService struct is necessary to support the new functionality introduced by the UpdateReceiver interface.


133-138: LGTM!

The implementation of the SetUpdateReceiver method in the syncStatusService 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 the UpdateReceiver interface. Proper error handling has been added.


34-35: LGTM! Ensure UpdateNodeStatus is implemented correctly.

The addition of the err return value for UpdateTree and the new method UpdateNodeStatus are good practices for error handling and functionality expansion.


55-55: LGTM! Ensure SetUpdateReceiver is implemented correctly.

The addition of the SetUpdateReceiver method allows for dynamic updating of the updateReceiver, which is a good practice for flexibility.

Verification successful

Verified Implementation of SetUpdateReceiver

The method SetUpdateReceiver is implemented within the syncStatusService struct and is referenced in the codebase, confirming the review comment's approval.

  • core/syncstatus/objectsyncstatus/syncstatus.go: Implementation of SetUpdateReceiver.
  • core/syncstatus/service.go: Reference to SetUpdateReceiver.
  • core/syncstatus/objectsyncstatus/syncstatus_test.go: Reference to SetUpdateReceiver.
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 the updateReceiver tests.


239-244: LGTM!

The fixture struct is necessary to organize the test components for the updateReceiver 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 the UpdateReceiver interface.

Copy link

github-actions bot commented Jul 2, 2024

New Coverage 46.5% of statements
Patch Coverage 56.9% of changed statements (41/72)

Coverage provided by https://github.com/seriousben/go-patch-cover-action

@AnastasiaShemyakinskaya AnastasiaShemyakinskaya merged commit 3722cfe into main Jul 2, 2024
5 checks passed
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya deleted the revert-objectsync-status-events branch July 2, 2024 15:11
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants