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

(OraklNode) Update restartFetcher #2241

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

nick-bisonai
Copy link
Collaborator

Description

  • Remove admin endpoint
  • activate/deactivate: fetcher start/stop based on config id isn't compatible anymore for websocket fetcher
  • Remove fetcher bus message command
  • ACTIVATE_FETCHER & DEACTIVATE_FETCHER: command no more compatible to run based on configID
  • Add WebsocketFetcher Stop func: include websocketFetcher Stop in fetcher app StopAll func

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this Aug 27, 2024
@nick-bisonai nick-bisonai requested a review from a team as a code owner August 27, 2024 13:32
Copy link
Contributor

coderabbitai bot commented Aug 27, 2024

Walkthrough

Walkthrough

The changes involve the removal of activation and deactivation functionalities for fetchers across multiple files, including the elimination of related HTTP routes and test cases. Additionally, modifications to the App struct in the websocket fetcher introduce new context management capabilities, allowing for better control over fetcher operations.

Changes

Files Change Summary
node/pkg/admin/fetcher/controller.go Removed activate and deactivate functions, affecting fetcher control via HTTP requests.
node/pkg/admin/fetcher/router.go Removed POST routes for /activate/:id and /deactivate/:id, simplifying the API.
node/pkg/admin/tests/fetcher_test.go Removed tests for fetcher activation and deactivation, reducing test coverage for these functions.
node/pkg/fetcher/app.go Removed ACTIVATE_FETCHER and DEACTIVATE_FETCHER cases, along with startFetcherById and stopFetcherById methods.
node/pkg/websocketfetcher/app.go Added cancel field to App, modified Start method for cancellable context, and introduced a new Stop method.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Router
    participant Controller
    participant App

    Client->>Router: POST /activate/:id
    Router->>Controller: activate(c)
    Controller->>App: startFetcherById(ctx, configId)
    App-->>Controller: Fetcher started
    Controller-->>Router: Response to client

    Client->>Router: POST /deactivate/:id
    Router->>Controller: deactivate(c)
    Controller->>App: stopFetcherById(ctx, configId)
    App-->>Controller: Fetcher stopped
    Controller-->>Router: Response to client
Loading

Poem

🐇 In the meadow, bright and fair,
Fetchers dance without a care.
No more toggles, just a breeze,
Cancellable, with graceful ease.
Hopping forth, we celebrate,
Changes made, oh how great! 🌼


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 Configuration 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.

Copy link
Contributor

@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 3f0cbbb and c2d0fcb.

Files selected for processing (5)
  • node/pkg/admin/fetcher/controller.go (1 hunks)
  • node/pkg/admin/fetcher/router.go (1 hunks)
  • node/pkg/admin/tests/fetcher_test.go (2 hunks)
  • node/pkg/fetcher/app.go (4 hunks)
  • node/pkg/websocketfetcher/app.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • node/pkg/admin/fetcher/router.go
Additional context used
Learnings (1)
Common learnings
Learnt from: nick-bisonai
PR: Bisonai/orakl#1280
File: node/pkg/fetcher/fetcher.go:267-267
Timestamp: 2024-03-19T13:22:13.702Z
Learning: Data insertion in the Orakl project is handled by `./core`, not `./node`, and references within `./api` are considered irrelevant to changes made in the PR context. This highlights the architectural separation between `./api`, `./core`, and `./node` within the project.
Additional comments not posted (19)
node/pkg/admin/tests/fetcher_test.go (3)

Line range hint 8-21: LGTM!

The test function is correctly implemented and tests the start functionality as expected.

The code changes are approved.


Line range hint 23-36: LGTM!

The test function is correctly implemented and tests the stop functionality as expected.

The code changes are approved.


Line range hint 38-51: LGTM!

The test function is correctly implemented and tests the refresh functionality as expected.

The code changes are approved.

node/pkg/admin/fetcher/controller.go (3)

Line range hint 9-19: LGTM!

The function is correctly implemented and handles the start request as expected.

The code changes are approved.


Line range hint 21-31: LGTM!

The function is correctly implemented and handles the stop request as expected.

The code changes are approved.


Line range hint 33-43: LGTM!

The function is correctly implemented and handles the refresh request as expected.

The code changes are approved.

node/pkg/websocketfetcher/app.go (3)

109-109: LGTM!

The addition of the cancel field to the App struct is a good practice for managing context cancellation.

The code changes are approved.


254-268: LGTM!

The modifications to the Start method improve the application's responsiveness to context cancellation.

The code changes are approved.


273-277: LGTM!

The addition of the Stop method is a good practice for managing the application's lifecycle.

The code changes are approved.

node/pkg/fetcher/app.go (10)

Line range hint 11-21: LGTM!

The function correctly initializes the App instance with the required components.

The code changes are approved.


Line range hint 23-28: LGTM!

The function correctly initializes the app and starts all fetchers.

The code changes are approved.


Line range hint 30-51: LGTM!

The function correctly subscribes to the message bus and handles incoming messages.

The code changes are approved.


Line range hint 53-94: LGTM!

The function correctly handles incoming messages and performs actions based on the command. The removal of ACTIVATE_FETCHER and DEACTIVATE_FETCHER cases aligns with the PR objectives.

The code changes are approved.


Line range hint 96-111: LGTM!

The function correctly starts all fetchers and related components. The addition of a.WebsocketFetcher.Start(ctx) ensures that the websocket fetcher is started.

The code changes are approved.


Line range hint 113-140: LGTM!

The function correctly stops all fetchers and related components. The addition of a.WebsocketFetcher.Stop() ensures that the websocket fetcher is stopped.

The code changes are approved.


Line range hint 248-303: LGTM!

The function correctly initializes the app with configurations, fetchers, and related components.

The code changes are approved.


Line range hint 143-151: LGTM!

The function correctly starts a specific fetcher.

The code changes are approved.


Line range hint 213-225: LGTM!

The function correctly stops a specific fetcher.

The code changes are approved.


Line range hint 305-307: LGTM!

The function correctly returns a string representation of the app.

The code changes are approved.

Copy link
Contributor

@Intizar-T Intizar-T left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@nick-bisonai nick-bisonai merged commit deae0ca into master Aug 28, 2024
1 check passed
@nick-bisonai nick-bisonai deleted the feat/restart-fetcher branch August 28, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants