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

Add confd.watch option, default as true. #826

Merged
merged 2 commits into from
Jan 14, 2025
Merged

Conversation

huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Jan 14, 2025

friendsofhyperf/confd#2

Summary by CodeRabbit

  • 新功能

    • 为配置文件添加了环境变量监控选项
    • 引入了可配置的监控功能开关
    • 支持监控特定的环境变量(如 DB_HOST)
  • 配置变更

    • 新增 CONFD_WATCH 环境变量控制监控状态
    • 默认启用监控功能
    • 可自定义监控间隔和监控的环境变量

Copy link

coderabbitai bot commented Jan 14, 2025

Warning

Rate limit exceeded

@huangdijia has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between da86636 and 16e3419.

📒 Files selected for processing (1)
  • src/confd/publish/confd.php (1 hunks)

概述

演练

此次更改主要涉及配置文件和监听器的修改,以增强环境变量监控功能。在 confd.php 配置文件中,新增了 watchwatches 配置选项,允许通过环境变量 CONFD_WATCH 控制是否启用监控。interval 配置项被更新为从环境变量 CONFD_INTERVAL 中获取值。WatchOnBootListener 类的构造函数被更新,增加了对配置接口的依赖,并在 process 方法中添加了根据配置决定是否继续监控的逻辑。

变更

文件 变更摘要
src/confd/publish/confd.php 新增 watch 布尔配置项,默认为 true;新增 watches 数组,初始包含 DB_HOST;更新 interval 从环境变量获取值
src/confd/src/Listener/WatchOnBootListener.php 构造函数增加 ConfigInterface 依赖;process 方法新增配置检查逻辑

诗歌

🐰 配置监听兔,灵动如春风
环境变量舞,轻轻触控中
开关随心动,监控不慌忙
代码如诗行,智慧闪光芒


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

@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

🧹 Nitpick comments (2)
src/confd/src/Listener/WatchOnBootListener.php (1)

46-49: 建议添加调试日志

当监听功能被禁用时,建议添加调试日志以便于问题排查。

建议修改如下:

 if (! $this->config->get('confd.watch', true)) {
+    $this->logger?->debug('[confd] Watching is disabled by configuration.');
     return;
 }
src/confd/publish/confd.php (1)

69-75: 建议完善配置文档

当前的配置注释较为简单,建议:

  1. watches 数组添加更详细的说明,包括配置格式和用途
  2. interval 添加单位说明(秒/毫秒)

建议修改注释如下:

-    // Watch keys
+    // 需要监听的环境变量列表
+    // 当这些变量发生变化时会触发更新
     'watches' => [
         'DB_HOST',
     ],

-    // Watch interval
+    // 配置检查间隔时间(秒)
+    // 系统会按照此间隔定期检查配置变更
     'interval' => 1,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 470f7f5 and da86636.

📒 Files selected for processing (2)
  • src/confd/publish/confd.php (1 hunks)
  • src/confd/src/Listener/WatchOnBootListener.php (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Test on PHP 8.1 with Swoole 6.0.0
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.6
  • GitHub Check: Test on PHP 8.2 with Swoole 6.0.0
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.6
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.0
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.6
  • GitHub Check: Test on PHP 8.1 with Swoole 6.0.0
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.6
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.6
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.0
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.6
🔇 Additional comments (2)
src/confd/src/Listener/WatchOnBootListener.php (1)

16-16: 依赖注入实现正确!

构造函数的依赖注入实现符合最佳实践,参数顺序合理。

Also applies to: 26-29

src/confd/publish/confd.php (1)

66-67: 配置项设计合理!

通过环境变量控制监听功能的实现方式符合最佳实践,默认值设置合理。

@huangdijia huangdijia marked this pull request as ready for review January 14, 2025 09:24
@huangdijia huangdijia merged commit e6c12b8 into main Jan 14, 2025
15 of 16 checks passed
@huangdijia huangdijia deleted the add-confd-watch-option branch January 14, 2025 09:24
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.

1 participant