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

chore: manage pool of workers directly in the plugin #113

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

rustatian
Copy link
Member

@rustatian rustatian commented Aug 30, 2024

Reason for This PR

ref: roadrunner-server/roadrunner#1986

Description of Changes

  • Since endure v2 we don't need to have a central place to shutdown pools of workers. So every plugin can independently maintain its own pool.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT license.

PR Checklist

[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Updated dependencies to enhance functionality and stability.
    • Improved error handling for subscription requests in the PHP integration.
  • Bug Fixes

    • Improved resource management strategy within the plugin, leading to a more streamlined shutdown process.
  • Refactor

    • Adjusted linting strategy for better detection of loop variable handling issues.
    • Enhanced test suite with context management and cross-platform compatibility.

@rustatian rustatian added the enhancement New feature or request label Aug 30, 2024
@rustatian rustatian requested a review from wolfy-j August 30, 2024 11:48
@rustatian rustatian self-assigned this Aug 30, 2024
Copy link

coderabbitai bot commented Aug 30, 2024

Walkthrough

The changes involve updates to the linting configuration in .golangci.yml, dependency versions in go.mod, and modifications to the Stop method in the Plugin struct within plugin.go. The linter exportloopref has been replaced with copyloopvar, dependencies have been updated for potential improvements, and the gRPC server shutdown process has been enhanced to include a graceful stop followed by resource cleanup. Additionally, logging has been added to methods in proxy.go, and test files have been adapted for better context management and cross-platform compatibility.

Changes

Files Change Summary
.golangci.yml Replaced exportloopref linter with copyloopvar.
go.mod, tests/go.mod Updated several dependencies, including github.com/prometheus/common and google.golang.org/grpc. Modified Go version from 1.23.0 to 1.23.
plugin.go Modified Stop method to use GracefulStop() for the gRPC server and invoked p.pool.Destroy(ctx) afterward.
proxy.go Added logging statements to methods in the Proxy struct for improved observability.
tests/centrifugo_test.go Enhanced test suite with context-aware HTTP requests and conditional command execution based on OS.
tests/php_test_files/centrifuge_connect.php Introduced error handling for subscription requests in the PHP test file.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant gRPCServer
    participant Pool

    Client->>gRPCServer: Stop()
    gRPCServer->>gRPCServer: GracefulStop()
    gRPCServer-->>Client: Acknowledgment
    gRPCServer->>Pool: Destroy(ctx)
Loading

Poem

🐇
In the meadow, changes bloom,
Linting tools sweep away the gloom.
Dependencies dance, a fresh new tune,
Servers stop with a gentle swoon.
Hooray for code, so neat and bright,
A rabbit's cheer in the moonlight! 🌙


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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Signed-off-by: Valery Piashchynski <[email protected]>
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

Outside diff range, codebase verification and nitpick comments (1)
plugin.go (1)

155-156: Approved method modification for graceful shutdown.

The changes to the Stop method, using GracefulStop for the gRPC server and immediately destroying the worker pool, are crucial for ensuring a controlled shutdown process. This should help in better resource management and reduce the risk of abrupt terminations.

The changes are approved.

Consider adding comments within the Stop method to explain the rationale behind these changes for future maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0a829f4 and ae6e5b1.

Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • go.work.sum is excluded by !**/*.sum
Files selected for processing (3)
  • .golangci.yml (1 hunks)
  • go.mod (2 hunks)
  • plugin.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • go.mod
Additional comments not posted (1)
.golangci.yml (1)

38-38: Approved linter change.

The replacement of exportloopref with copyloopvar is noted. This change should help in better handling of loop variable issues in Go code.

The change is approved.

Consider running the linter on the existing codebase to ensure that this change does not introduce new linting errors or overlook potential issues that were previously detected.

Signed-off-by: Valery Piashchynski <[email protected]>
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 ae6e5b1 and cb9fc70.

Files ignored due to path filters (2)
  • go.work.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
Files selected for processing (5)
  • .golangci.yml (2 hunks)
  • proxy.go (7 hunks)
  • tests/centrifugo_test.go (7 hunks)
  • tests/go.mod (4 hunks)
  • tests/php_test_files/centrifuge_connect.php (1 hunks)
Files skipped from review due to trivial changes (2)
  • .golangci.yml
  • proxy.go
Additional comments not posted (4)
tests/php_test_files/centrifuge_connect.php (1)

29-36: Properly implemented error handling for subscription requests.

The new conditional block for handling Request\Subscribe instances is correctly implemented with appropriate error handling. The use of continue ensures that the loop can proceed without interruption.

The code changes are approved.

tests/go.mod (1)

Line range hint 3-81: Dependency updates reviewed.

The updates to the Go version and dependencies in go.mod are noted. It's important to ensure that these updates do not introduce breaking changes and are compatible with the project's existing codebase.

The dependency updates are approved, but it is recommended to verify their integration and test extensively to ensure compatibility.

tests/centrifugo_test.go (2)

Line range hint 228-240: Enhanced HTTP request management with context.

The replacement of http.NewRequest with http.NewRequestWithContext is a significant improvement, allowing for better management of request timeouts and cancellations.

The changes are approved and align with best practices for HTTP request handling in Go.


40-45: Improved cross-platform compatibility in command execution.

The introduction of conditional command execution based on runtime.GOOS enhances the test suite's flexibility and ensures that the correct executable is invoked based on the operating system.

The changes are approved, but it is recommended to perform thorough testing on different platforms to ensure consistent behavior.

@rustatian rustatian merged commit d40870b into master Aug 30, 2024
6 checks passed
@rustatian rustatian deleted the chore/pool-shutdown branch August 30, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant