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

feat: add echo command #72

Merged
merged 6 commits into from
Dec 28, 2024
Merged

feat: add echo command #72

merged 6 commits into from
Dec 28, 2024

Conversation

Antarctica000
Copy link
Collaborator

@Antarctica000 Antarctica000 commented Nov 14, 2024

This PR adds the functionality for the echo command to the add_echo_cmd branch. The command will return the arguments provided by the user as output.

fix #19

Summary by CodeRabbit

  • New Features

    • Introduced a new command Echo that allows users to concatenate arguments and return a formatted response.
    • Added a new constant kCmdNameEcho to enhance command name definitions.
  • Bug Fixes

    • No bug fixes were made in this release.
  • Documentation

    • Updated command table to include the new Echo command that requires two parameters.

Copy link

coderabbitai bot commented Nov 14, 2024

Walkthrough

The changes introduced in this pull request involve the addition of a new command named Echo to the command handling system in the kiwi namespace. This includes the creation of a new constant kCmdNameEcho, a new command class EchoCmd, and the integration of the Echo command into the command table. The existing command structure remains unchanged, with no modifications to existing commands or their functionalities.

Changes

File Change Summary
src/base_cmd.h Added constant: const std::string kCmdNameEcho = "echo"; in namespace kiwi.
src/cmd_admin.cc Added class EchoCmd extending BaseCmd, with methods: EchoCmd::EchoCmd, DoInitial, and DoCmd.
src/cmd_admin.h Added class EchoCmd, constructor, and method signatures for DoInitial and DoCmd.
src/cmd_table_manager.cc Added command Echo with argument count 2 in CmdTableManager::InitCmdTable().

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant CmdTableManager
    participant EchoCmd

    Client->>CmdTableManager: Request Echo Command
    CmdTableManager->>EchoCmd: Initialize Command
    EchoCmd->>Client: Return Echo Response
Loading

"In the land of code, where commands do play,
A new echo arises, brightening the day.
With arguments few, it speaks with delight,
A whisper of echoes, in the soft moonlight.
Hopping through functions, so lively and spry,
Here's to the changes, oh my, oh my!" 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between e578b32 and f117a9b.

📒 Files selected for processing (2)
  • src/cmd_admin.cc (2 hunks)
  • src/cmd_table_manager.cc (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cmd_table_manager.cc

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

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.

@Antarctica000 Antarctica000 changed the title Add EchoCmd feat: add echo cmd Nov 14, 2024
@Antarctica000 Antarctica000 changed the title feat: add echo cmd feat: add echo command Nov 14, 2024
@luky116
Copy link
Collaborator

luky116 commented Nov 16, 2024

cmake-build 文件不要传上来

@@ -35,8 +35,7 @@ concept HasSetFdFunction = requires(T t, uint64_t id, int8_t index) {
{ (*t).GetConnId() } -> std::same_as<uint64_t>; // GetFd return type is int
{ (*t).SetThreadIndex(index) } -> std::same_as<void>; // SetThreadIndex return type is void
{ (*t).GetThreadIndex() } -> std::same_as<int8_t>; // GetThreadIndex return type is int8_t
}
|| std::is_class_v<T>; // If T is an ordinary class, the member function is called directly
Copy link
Collaborator

Choose a reason for hiding this comment

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

这种没改动的,不要提交上来

@AlexStocks
Copy link
Contributor

 有文件冲突了,烦请处理下

src/cmd_admin.cc Outdated
response += client->argv_[i];
}

client->SetRes(CmdRes::kEcho, response);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里没必要使用 client->SetRes 返回数据,同理,上面也没必要在 CmdRet 中 新加一个类型,直接返回对应的数据就行

@@ -56,6 +56,7 @@ void CmdTableManager::InitCmdTable() {
ADD_SUBCOMMAND(Config, Get, -3);
ADD_SUBCOMMAND(Config, Set, -4);
ADD_COMMAND(Ping, 0);
ADD_COMMAND(Echo, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里应该是 -1 具体可以参考redis

src/client.cc Outdated
case kEcho:
AppendStringRaw("+");
AppendStringRaw(content);
AppendStringRaw(CRLF);
Copy link
Collaborator

Choose a reason for hiding this comment

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

调用 AppendSimpleString

@marsevilspirit
Copy link
Collaborator

I will carry out the subsequent work.

@luky116 luky116 merged commit d79747d into unstable Dec 28, 2024
2 of 6 checks passed
@AlexStocks AlexStocks deleted the add_echo_cmd branch January 11, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support echo commnd
6 participants