-
Notifications
You must be signed in to change notification settings - Fork 38
eventstore: Refactor subscription removal using slices.Delete #4174
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
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @wk989898, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the method used to remove subscription states within the event store. By adopting the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughThis PR refactors subscription removal logic in the event store by replacing manual slice manipulation with Go's standard Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the subscription removal logic in event_store.go to use the slices.Delete function, which is a good improvement for code readability. However, the slices package is not imported in the file, which will cause a compilation error. This critical issue needs to be addressed.
| log.Panic("cannot find subscription state", zap.Uint64("subscriptionID", change.SubID)) | ||
| } | ||
| tableState.Subscriptions = append(tableState.Subscriptions[:targetIndex], tableState.Subscriptions[targetIndex+1:]...) | ||
| tableState.Subscriptions = slices.Delete(tableState.Subscriptions, targetIndex, targetIndex+1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@logservice/eventstore/event_store.go`:
- Line 1492: The code calls slices.Delete on tableState.Subscriptions (line
using slices.Delete) but the "slices" package is not imported; add the standard
library import "slices" to the import block so the call to slices.Delete
compiles, ensuring the import is placed with other stdlib imports and not in a
separate grouped import.
| log.Panic("cannot find subscription state", zap.Uint64("subscriptionID", change.SubID)) | ||
| } | ||
| tableState.Subscriptions = append(tableState.Subscriptions[:targetIndex], tableState.Subscriptions[targetIndex+1:]...) | ||
| tableState.Subscriptions = slices.Delete(tableState.Subscriptions, targetIndex, targetIndex+1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Check the import block and search for slices usage
head -50 logservice/eventstore/event_store.go | tail -35
# Also search for all slices usages
echo "---"
rg -n 'slices\.' logservice/eventstore/event_store.goRepository: pingcap/ticdc
Length of output: 1172
Missing slices import — this won't compile.
slices.Delete is used at line 1492 but the "slices" package is not imported. Add "slices" to the standard library import group:
import (
"bytes"
"context"
"fmt"
"math"
"os"
+ "slices"
"strconv"
"sync"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tableState.Subscriptions = slices.Delete(tableState.Subscriptions, targetIndex, targetIndex+1) | |
| import ( | |
| "bytes" | |
| "context" | |
| "fmt" | |
| "math" | |
| "os" | |
| "slices" | |
| "strconv" | |
| "sync" | |
| // ... rest of imports | |
| ) |
🤖 Prompt for AI Agents
In `@logservice/eventstore/event_store.go` at line 1492, The code calls
slices.Delete on tableState.Subscriptions (line using slices.Delete) but the
"slices" package is not imported; add the standard library import "slices" to
the import block so the call to slices.Delete compiles, ensuring the import is
placed with other stdlib imports and not in a separate grouped import.
What problem does this PR solve?
Issue Number: close #4142
What is changed and how it works?
Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit