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

feature:ETCD key value mvcc #14

Merged
merged 1 commit into from
Nov 13, 2024
Merged

feature:ETCD key value mvcc #14

merged 1 commit into from
Nov 13, 2024

Conversation

gongna-au
Copy link
Owner

@gongna-au gongna-au commented Nov 13, 2024

Please note that if you are trying to update your website, this is the wrong place to do so. Please carefully follow the Beautiful Jekyll instructions (found at https://github.com/daattali/beautiful-jekyll#readme) and make sure you submit changes to your version of the project.

If your intention is to submit a Pull Request, please describe what your pull request achieves.

Thank you!

Summary by CodeRabbit

  • New Features

    • Introduced a new Markdown file with a complete Go implementation for managing key-value pairs using etcd.
    • Added functionality for creating an etcd client, retrieving key values, and handling updates with multi-version concurrency control (MVCC).
    • Implemented error handling and lifecycle management for key-value pairs.
  • Documentation

    • Added a comprehensive explanation of the new key-value management features and their usage.

Copy link

coderabbitai bot commented Nov 13, 2024

Walkthrough

This pull request introduces a new Markdown file that contains a complete Go implementation for managing key-value pairs using etcd with multi-version concurrency control (MVCC). The implementation includes functions for creating an etcd client, retrieving key values, managing key-value lifecycle, and handling concurrency. It defines a LocalKeyValue struct for encapsulating key, value, and revision data, along with methods for reading and writing values. The main function orchestrates the flow of operations, emphasizing error handling and synchronization with etcd.

Changes

File Path Change Summary
_posts/2024-11-11-test-markdown.md Added a complete Go implementation for managing key-value pairs with etcd, including functions for client creation, key retrieval, lifecycle management, and concurrency handling. New struct and methods defined for key-value operations.

Poem

In the burrow where code does play,
A new client hops in, bright as day.
With keys and values, oh what a sight,
Watching changes, all day and night!
Error handling, smooth as a breeze,
In our code garden, we code with ease! 🐇✨


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

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: 4

🧹 Outside diff range and nitpick comments (2)
_posts/2024-11-11-test-markdown.md (2)

1-7: Consider adding more descriptive metadata

The front matter is properly formatted but could benefit from:

  • A more descriptive subtitle explaining the MVCC implementation
  • Additional tags like "ETCD", "MVCC", "Distributed-Systems"

92-116: Enhance MVCC write implementation

The Write method's transaction implementation could be improved for better error handling and clarity.

Consider:

  1. Adding context with timeout
  2. Improving error messages
  3. Adding retry mechanism for write conflicts
-func (lkv *LocalKeyValue) Write(cli *clientv3.Client, newValue string) error {
+func (lkv *LocalKeyValue) Write(ctx context.Context, cli *clientv3.Client, newValue string) error {
+    const maxRetries = 3
+    var attempt int
+    for attempt < maxRetries {
+        if err := lkv.tryWrite(ctx, cli, newValue); err != nil {
+            if err == ErrWriteConflict && attempt < maxRetries-1 {
+                attempt++
+                time.Sleep(time.Duration(attempt) * 100 * time.Millisecond)
+                continue
+            }
+            return err
+        }
+        return nil
+    }
+    return fmt.Errorf("failed to write after %d attempts", maxRetries)
 }
🧰 Tools
🪛 Markdownlint

93-93: Column: 1
Hard tabs

(MD010, no-hard-tabs)


94-94: Column: 1
Hard tabs

(MD010, no-hard-tabs)


95-95: Column: 1
Hard tabs

(MD010, no-hard-tabs)


96-96: Column: 1
Hard tabs

(MD010, no-hard-tabs)


97-97: Column: 1
Hard tabs

(MD010, no-hard-tabs)


98-98: Column: 1
Hard tabs

(MD010, no-hard-tabs)


99-99: Column: 1
Hard tabs

(MD010, no-hard-tabs)


100-100: Column: 1
Hard tabs

(MD010, no-hard-tabs)


101-101: Column: 1
Hard tabs

(MD010, no-hard-tabs)


102-102: Column: 1
Hard tabs

(MD010, no-hard-tabs)


103-103: Column: 1
Hard tabs

(MD010, no-hard-tabs)


104-104: Column: 1
Hard tabs

(MD010, no-hard-tabs)


105-105: Column: 1
Hard tabs

(MD010, no-hard-tabs)


106-106: Column: 1
Hard tabs

(MD010, no-hard-tabs)


107-107: Column: 1
Hard tabs

(MD010, no-hard-tabs)


108-108: Column: 1
Hard tabs

(MD010, no-hard-tabs)


109-109: Column: 1
Hard tabs

(MD010, no-hard-tabs)


110-110: Column: 1
Hard tabs

(MD010, no-hard-tabs)


111-111: Column: 1
Hard tabs

(MD010, no-hard-tabs)


112-112: Column: 1
Hard tabs

(MD010, no-hard-tabs)


113-113: Column: 1
Hard tabs

(MD010, no-hard-tabs)


114-114: Column: 1
Hard tabs

(MD010, no-hard-tabs)


115-115: Column: 1
Hard tabs

(MD010, no-hard-tabs)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bf58608 and da6cc4b.

📒 Files selected for processing (1)
  • _posts/2024-11-11-test-markdown.md (1 hunks)
🧰 Additional context used
🪛 Markdownlint
_posts/2024-11-11-test-markdown.md

16-16: Column: 1
Hard tabs

(MD010, no-hard-tabs)


17-17: Column: 1
Hard tabs

(MD010, no-hard-tabs)


18-18: Column: 1
Hard tabs

(MD010, no-hard-tabs)


20-20: Column: 1
Hard tabs

(MD010, no-hard-tabs)


25-25: Column: 1
Hard tabs

(MD010, no-hard-tabs)


26-26: Column: 1
Hard tabs

(MD010, no-hard-tabs)


27-27: Column: 1
Hard tabs

(MD010, no-hard-tabs)


28-28: Column: 1
Hard tabs

(MD010, no-hard-tabs)


29-29: Column: 1
Hard tabs

(MD010, no-hard-tabs)


30-30: Column: 1
Hard tabs

(MD010, no-hard-tabs)


31-31: Column: 1
Hard tabs

(MD010, no-hard-tabs)


32-32: Column: 1
Hard tabs

(MD010, no-hard-tabs)


33-33: Column: 1
Hard tabs

(MD010, no-hard-tabs)


34-34: Column: 1
Hard tabs

(MD010, no-hard-tabs)


39-39: Column: 1
Hard tabs

(MD010, no-hard-tabs)


40-40: Column: 1
Hard tabs

(MD010, no-hard-tabs)


41-41: Column: 1
Hard tabs

(MD010, no-hard-tabs)


42-42: Column: 1
Hard tabs

(MD010, no-hard-tabs)


43-43: Column: 1
Hard tabs

(MD010, no-hard-tabs)


44-44: Column: 1
Hard tabs

(MD010, no-hard-tabs)


45-45: Column: 1
Hard tabs

(MD010, no-hard-tabs)


46-46: Column: 1
Hard tabs

(MD010, no-hard-tabs)


47-47: Column: 1
Hard tabs

(MD010, no-hard-tabs)


52-52: Column: 1
Hard tabs

(MD010, no-hard-tabs)


53-53: Column: 1
Hard tabs

(MD010, no-hard-tabs)


54-54: Column: 1
Hard tabs

(MD010, no-hard-tabs)


58-58: Column: 1
Hard tabs

(MD010, no-hard-tabs)


59-59: Column: 1
Hard tabs

(MD010, no-hard-tabs)


60-60: Column: 1
Hard tabs

(MD010, no-hard-tabs)


61-61: Column: 1
Hard tabs

(MD010, no-hard-tabs)


62-62: Column: 1
Hard tabs

(MD010, no-hard-tabs)


67-67: Column: 1
Hard tabs

(MD010, no-hard-tabs)


68-68: Column: 1
Hard tabs

(MD010, no-hard-tabs)


69-69: Column: 1
Hard tabs

(MD010, no-hard-tabs)


70-70: Column: 1
Hard tabs

(MD010, no-hard-tabs)


71-71: Column: 1
Hard tabs

(MD010, no-hard-tabs)


72-72: Column: 1
Hard tabs

(MD010, no-hard-tabs)


73-73: Column: 1
Hard tabs

(MD010, no-hard-tabs)


74-74: Column: 1
Hard tabs

(MD010, no-hard-tabs)


75-75: Column: 1
Hard tabs

(MD010, no-hard-tabs)


76-76: Column: 1
Hard tabs

(MD010, no-hard-tabs)


77-77: Column: 1
Hard tabs

(MD010, no-hard-tabs)


78-78: Column: 1
Hard tabs

(MD010, no-hard-tabs)


79-79: Column: 1
Hard tabs

(MD010, no-hard-tabs)


80-80: Column: 1
Hard tabs

(MD010, no-hard-tabs)


81-81: Column: 1
Hard tabs

(MD010, no-hard-tabs)


82-82: Column: 1
Hard tabs

(MD010, no-hard-tabs)


83-83: Column: 1
Hard tabs

(MD010, no-hard-tabs)


88-88: Column: 1
Hard tabs

(MD010, no-hard-tabs)


93-93: Column: 1
Hard tabs

(MD010, no-hard-tabs)


94-94: Column: 1
Hard tabs

(MD010, no-hard-tabs)


95-95: Column: 1
Hard tabs

(MD010, no-hard-tabs)


96-96: Column: 1
Hard tabs

(MD010, no-hard-tabs)


97-97: Column: 1
Hard tabs

(MD010, no-hard-tabs)


98-98: Column: 1
Hard tabs

(MD010, no-hard-tabs)


99-99: Column: 1
Hard tabs

(MD010, no-hard-tabs)


100-100: Column: 1
Hard tabs

(MD010, no-hard-tabs)


101-101: Column: 1
Hard tabs

(MD010, no-hard-tabs)


102-102: Column: 1
Hard tabs

(MD010, no-hard-tabs)


103-103: Column: 1
Hard tabs

(MD010, no-hard-tabs)


104-104: Column: 1
Hard tabs

(MD010, no-hard-tabs)


105-105: Column: 1
Hard tabs

(MD010, no-hard-tabs)


106-106: Column: 1
Hard tabs

(MD010, no-hard-tabs)


107-107: Column: 1
Hard tabs

(MD010, no-hard-tabs)


108-108: Column: 1
Hard tabs

(MD010, no-hard-tabs)


109-109: Column: 1
Hard tabs

(MD010, no-hard-tabs)


110-110: Column: 1
Hard tabs

(MD010, no-hard-tabs)


111-111: Column: 1
Hard tabs

(MD010, no-hard-tabs)


112-112: Column: 1
Hard tabs

(MD010, no-hard-tabs)


113-113: Column: 1
Hard tabs

(MD010, no-hard-tabs)


114-114: Column: 1
Hard tabs

(MD010, no-hard-tabs)


115-115: Column: 1
Hard tabs

(MD010, no-hard-tabs)


119-119: Column: 1
Hard tabs

(MD010, no-hard-tabs)


120-120: Column: 1
Hard tabs

(MD010, no-hard-tabs)


121-121: Column: 1
Hard tabs

(MD010, no-hard-tabs)


122-122: Column: 1
Hard tabs

(MD010, no-hard-tabs)


123-123: Column: 1
Hard tabs

(MD010, no-hard-tabs)


124-124: Column: 1
Hard tabs

(MD010, no-hard-tabs)


126-126: Column: 1
Hard tabs

(MD010, no-hard-tabs)


128-128: Column: 1
Hard tabs

(MD010, no-hard-tabs)


129-129: Column: 1
Hard tabs

(MD010, no-hard-tabs)


130-130: Column: 1
Hard tabs

(MD010, no-hard-tabs)


131-131: Column: 1
Hard tabs

(MD010, no-hard-tabs)


132-132: Column: 1
Hard tabs

(MD010, no-hard-tabs)


133-133: Column: 1
Hard tabs

(MD010, no-hard-tabs)


134-134: Column: 1
Hard tabs

(MD010, no-hard-tabs)


135-135: Column: 1
Hard tabs

(MD010, no-hard-tabs)


136-136: Column: 1
Hard tabs

(MD010, no-hard-tabs)


137-137: Column: 1
Hard tabs

(MD010, no-hard-tabs)


138-138: Column: 1
Hard tabs

(MD010, no-hard-tabs)


139-139: Column: 1
Hard tabs

(MD010, no-hard-tabs)


141-141: Column: 1
Hard tabs

(MD010, no-hard-tabs)


142-142: Column: 1
Hard tabs

(MD010, no-hard-tabs)


143-143: Column: 1
Hard tabs

(MD010, no-hard-tabs)


145-145: Column: 1
Hard tabs

(MD010, no-hard-tabs)


146-146: Column: 1
Hard tabs

(MD010, no-hard-tabs)


147-147: Column: 1
Hard tabs

(MD010, no-hard-tabs)


149-149: Column: 1
Hard tabs

(MD010, no-hard-tabs)


150-150: Column: 1
Hard tabs

(MD010, no-hard-tabs)


151-151: Column: 1
Hard tabs

(MD010, no-hard-tabs)


152-152: Column: 1
Hard tabs

(MD010, no-hard-tabs)


153-153: Column: 1
Hard tabs

(MD010, no-hard-tabs)

_posts/2024-11-11-test-markdown.md Show resolved Hide resolved
_posts/2024-11-11-test-markdown.md Show resolved Hide resolved
_posts/2024-11-11-test-markdown.md Show resolved Hide resolved
_posts/2024-11-11-test-markdown.md Show resolved Hide resolved
@gongna-au gongna-au merged commit e958cec into master Nov 13, 2024
3 checks passed
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