-
Notifications
You must be signed in to change notification settings - Fork 2
distribution: own default group route #295
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
Conversation
Summary of ChangesHello @bootjp, 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 how the default group ID and routing are managed within the Highlights
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
|
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 is a nice improvement that simplifies the demo server configuration by making the distribution engine responsible for its own default route. This enhances encapsulation and removes unnecessary configuration plumbing. The implementation looks correct.
My main feedback is regarding the lack of tests for the new NewEngineWithDefaultRoute function. I've added a review comment with a suggested unit test to ensure the new functionality is covered and to prevent future regressions.
| func NewEngineWithDefaultRoute() *Engine { | ||
| engine := NewEngine() | ||
| engine.UpdateRoute([]byte(""), nil, defaultGroupID) | ||
| return engine | ||
| } |
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.
This new constructor is a great addition for simplifying setup. However, new public functions should be accompanied by unit tests to ensure they behave as expected and prevent future regressions. The PR description mentions no tests were run for this change.
Please add a unit test for NewEngineWithDefaultRoute to distribution/engine_test.go. Here is a suggested test case:
func TestNewEngineWithDefaultRoute(t *testing.T) {
e := NewEngineWithDefaultRoute()
stats := e.Stats()
if len(stats) != 1 {
t.Fatalf("expected 1 route, got %d", len(stats))
}
r := stats[0]
if r.GroupID != defaultGroupID {
t.Fatalf("expected group ID %d, got %d", defaultGroupID, r.GroupID)
}
if !bytes.Equal(r.Start, []byte("")) {
t.Fatalf("expected start of keyspace (empty slice), got %q", r.Start)
}
if r.End != nil {
t.Fatalf("expected end of keyspace (nil), got %q", r.End)
}
// Also test via GetRoute
route, ok := e.GetRoute([]byte("any-key"))
if !ok {
t.Fatal("GetRoute should find the default route")
}
if route.GroupID != defaultGroupID {
t.Fatalf("GetRoute: expected group ID %d, got %d", defaultGroupID, route.GroupID)
}
}
Motivation
raftGroupIDplumbing and relying on engine-initialized routing.Description
defaultGroupIDand a new constructorNewEngineWithDefaultRouteindistribution/engine.gothat registers a default route covering the full keyspace.distribution.NewEngine()+UpdateRoute(..., cfg.raftGroupID)withdistribution.NewEngineWithDefaultRoute()incmd/server/demo.go.--raftGroupIdCLI flag and correspondingraftGroupIDconfig field and sample values from the demo server.setupGRPCto accept thedistServerand register the distribution gRPC service withpb.RegisterDistributionServer.Testing
gofmt -won modified files and formatting succeeded.go testunit or integration tests were executed for this change.Codex Task