Refactor project layout and add remote write control#7
Merged
Suhaibinator merged 2 commits intomainfrom May 17, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the project layout while adding support for controlling remote write operations via a new configuration flag and environment variable. Key changes include moving server code under internal/server, introducing the ALLOW_REMOTE_WRITES configuration (and corresponding command-line flag), and updating tests and documentation to reflect this new feature.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/server/server_test.go | Updated import path and set allowRemoteWrites to true in tests. |
| internal/server/server.go | Added allowRemoteWrites flag checks to restrict remote write operations. |
| errors/errors.go | Added a new error constant for disabled remote writes. |
| config/configuration.go | Introduced configuration constant and variable for remote writes. |
| cmd/smq/main.go | Included a new flag/option to control remote write operations. |
| README.md | Documented the new remote writes configuration option. |
Comment on lines
37
to
+40
| func (s *Server) Produce(ctx context.Context, pr *pb.ProduceRequest) (*pb.ProduceResponse, error) { | ||
| if !s.allowRemoteWrites { | ||
| return nil, smqerrors.ErrRemoteWritesDisabled | ||
| } |
There was a problem hiding this comment.
[nitpick] Consider abstracting the remote write permission check into a helper function to avoid repetitive code across multiple endpoints.
Suggested change
| func (s *Server) Produce(ctx context.Context, pr *pb.ProduceRequest) (*pb.ProduceResponse, error) { | |
| if !s.allowRemoteWrites { | |
| return nil, smqerrors.ErrRemoteWritesDisabled | |
| } | |
| func (s *Server) checkRemoteWritePermission() error { | |
| if !s.allowRemoteWrites { | |
| return smqerrors.ErrRemoteWritesDisabled | |
| } | |
| return nil | |
| } | |
| func (s *Server) Produce(ctx context.Context, pr *pb.ProduceRequest) (*pb.ProduceResponse, error) { | |
| if err := s.checkRemoteWritePermission(); err != nil { | |
| return nil, err | |
| } |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cmd/smqinternal/serverALLOW_REMOTE_WRITESand--allow-remote-writes