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: support redis transaction #10

Open
wants to merge 6 commits into
base: unstable
Choose a base branch
from
Open

Conversation

panlei-coder
Copy link
Collaborator

@panlei-coder panlei-coder commented Aug 31, 2024

#11

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a transaction management system allowing clients to watch keys, execute multi-commands, and handle notifications for changes.
    • Added new commands for transaction management: Multi, Watch, UnWatch, Exec, and Discard.
    • Enhanced command handling with improved error reporting and validation processes.
    • Added new response types and methods in the command response handling system.
  • Bug Fixes

    • Improved error handling and command execution feedback for clients.
  • Documentation

    • Updated test suite to reflect new naming conventions and transaction handling logic.
  • Chores

    • Reduced the maximum number of databases from 16 to 6 in configuration.

Copy link

coderabbitai bot commented Aug 31, 2024

Walkthrough

The changes encompass modifications to several files within the codebase, including updates to naming conventions, enhancements in command handling and transaction management, the introduction of new methods and enumerators, and adjustments to configuration files. These alterations collectively improve the functionality and maintainability of the system, particularly in relation to command execution and error handling.

Changes

Files Change Summary
src/base_cmd.h Renamed constant kCmdNameUnwatch to kCmdNameUnWatch.
src/client.cc, src/client.h Enhanced command handling in PClient, added new enumerators in CmdRes, and introduced new methods.
src/cmd_table_manager.cc Added transaction-related commands in InitCmdTable.
src/cmd_thread_pool_worker.cc, src/cmd_thread_pool_worker.h Updated error handling and declared cmd_table_manager_ as an external variable.
src/net/callback_function.h, src/net/event_server.h, src/net/thread_manager.h Made formatting changes to improve readability without altering functionality.
src/store.cc, src/store.h Introduced new overloaded Propagate functions and declared external variable g_dirtyKeys.
tests/assets/default.conf Reduced the number of databases from 16 to 6.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PTransaction
    participant Database

    Client->>PTransaction: Watch(key)
    PTransaction->>Database: NotifyDirty(key)
    Database-->>PTransaction: Acknowledge
    PTransaction-->>Client: Confirmation
Loading

🐇 "In the garden where changes bloom,
New commands dance, dispelling gloom.
With each hop, I see the light,
Transactions handled, all feels right!
A world of data, bright and clear,
Hopping forward, no need to fear!" 🐇


Recent review details
Commits

Files that changed from the base of the PR and between 540e641 and f0264f5.

Files selected for processing (12)
  • src/base_cmd.h (1 hunks)
  • src/client.cc (5 hunks)
  • src/client.h (4 hunks)
  • src/cmd_table_manager.cc (2 hunks)
  • src/cmd_thread_pool_worker.cc (1 hunks)
  • src/cmd_thread_pool_worker.h (2 hunks)
  • src/net/callback_function.h (1 hunks)
  • src/net/event_server.h (2 hunks)
  • src/net/thread_manager.h (3 hunks)
  • src/store.cc (2 hunks)
  • src/store.h (1 hunks)
  • tests/assets/default.conf (1 hunks)

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

@AlexStocks AlexStocks requested review from lqxhub and dingxiaoshuai123 and removed request for lqxhub and dingxiaoshuai123 August 31, 2024 13:13
@longfar-ncy
Copy link
Collaborator

@Iam-WenYi 麻煩review一下

Copy link
Collaborator

@Iam-WenYi Iam-WenYi left a comment

Choose a reason for hiding this comment

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

需要做更多了解才行,现在还不可以下定论。
首先,项目目前是 Kiwi,已经不再是 PikiwiDB,因此注释方面需要调整。
指令方面,建议把 Multi 指令的注释迁移到 Multi 处,不要放在 Watch 处。
其它的话,可以看出这种事务的思路是参考了 Redis 的,即把要处理的任务放到一个队列之中,同时结合了 Kiwi 项目自身任务池的特点来的,但是我个人认为还需要进一步优化,因此还不能够予以通过。

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.

5 participants