-
Notifications
You must be signed in to change notification settings - Fork 4.6k
GRPC stub for the ResourceService #16528
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
Merged
+2,507
−63
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c44cef8
wip
analogue 51ddf57
make protbuf linter happy
analogue 853076b
Add no-op tests
analogue 0d10b4e
Merge branch 'main' into spatel/NET-2685-grpc-resource-service-stub
analogue 73fee3f
Update Watch endpoints to a read op for rate limiting
analogue c0c7a74
Merge branch 'spatel/NET-2685-grpc-resource-service-stub' of github.c…
analogue f6a0dda
Merge branch 'main' into spatel/NET-2685-grpc-resource-service-stub
analogue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package resource | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "google.golang.org/grpc" | ||
|
|
||
| "github.com/hashicorp/consul/proto-public/pbresource" | ||
| ) | ||
|
|
||
| type Server struct { | ||
| Config | ||
| } | ||
|
|
||
| type Config struct { | ||
| } | ||
|
|
||
| func NewServer(cfg Config) *Server { | ||
| return &Server{cfg} | ||
| } | ||
|
|
||
| var _ pbresource.ResourceServiceServer = (*Server)(nil) | ||
|
|
||
| func (s *Server) Register(grpcServer *grpc.Server) { | ||
| pbresource.RegisterResourceServiceServer(grpcServer, s) | ||
| } | ||
|
|
||
| func (s *Server) Read(ctx context.Context, req *pbresource.ReadRequest) (*pbresource.ReadResponse, error) { | ||
| // TODO | ||
| return &pbresource.ReadResponse{}, nil | ||
| } | ||
|
|
||
| func (s *Server) Write(ctx context.Context, req *pbresource.WriteRequest) (*pbresource.WriteResponse, error) { | ||
| // TODO | ||
| return &pbresource.WriteResponse{}, nil | ||
| } | ||
|
|
||
| func (s *Server) WriteStatus(ctx context.Context, req *pbresource.WriteStatusRequest) (*pbresource.WriteStatusResponse, error) { | ||
| // TODO | ||
| return &pbresource.WriteStatusResponse{}, nil | ||
| } | ||
|
|
||
| func (s *Server) List(ctx context.Context, req *pbresource.ListRequest) (*pbresource.ListResponse, error) { | ||
| // TODO | ||
| return &pbresource.ListResponse{}, nil | ||
| } | ||
|
|
||
| func (s *Server) Delete(ctx context.Context, req *pbresource.DeleteRequest) (*pbresource.DeleteResponse, error) { | ||
| // TODO | ||
| return &pbresource.DeleteResponse{}, nil | ||
| } | ||
|
|
||
| func (s *Server) Watch(req *pbresource.WatchRequest, ws pbresource.ResourceService_WatchServer) error { | ||
| // TODO | ||
| return nil | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package resource | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| "google.golang.org/grpc" | ||
|
|
||
| "github.com/hashicorp/consul/agent/grpc-external/testutils" | ||
| "github.com/hashicorp/consul/proto-public/pbresource" | ||
| ) | ||
|
|
||
| func testClient(t *testing.T, server *Server) pbresource.ResourceServiceClient { | ||
| t.Helper() | ||
|
|
||
| addr := testutils.RunTestServer(t, server) | ||
|
|
||
| //nolint:staticcheck | ||
| conn, err := grpc.DialContext(context.Background(), addr.String(), grpc.WithInsecure()) | ||
| require.NoError(t, err) | ||
| t.Cleanup(func() { | ||
| require.NoError(t, conn.Close()) | ||
| }) | ||
|
|
||
| return pbresource.NewResourceServiceClient(conn) | ||
| } | ||
|
|
||
| func TestRead_TODO(t *testing.T) { | ||
| server := NewServer(Config{}) | ||
| client := testClient(t, server) | ||
| resp, err := client.Read(context.Background(), &pbresource.ReadRequest{}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, resp) | ||
| } | ||
|
|
||
| func TestWrite_TODO(t *testing.T) { | ||
| server := NewServer(Config{}) | ||
| client := testClient(t, server) | ||
| resp, err := client.Write(context.Background(), &pbresource.WriteRequest{}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, resp) | ||
| } | ||
|
|
||
| func TestWriteStatus_TODO(t *testing.T) { | ||
| server := NewServer(Config{}) | ||
| client := testClient(t, server) | ||
| resp, err := client.WriteStatus(context.Background(), &pbresource.WriteStatusRequest{}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, resp) | ||
| } | ||
|
|
||
| func TestList_TODO(t *testing.T) { | ||
| server := NewServer(Config{}) | ||
| client := testClient(t, server) | ||
| resp, err := client.List(context.Background(), &pbresource.ListRequest{}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, resp) | ||
| } | ||
|
|
||
| func TestDelete_TODO(t *testing.T) { | ||
| server := NewServer(Config{}) | ||
| client := testClient(t, server) | ||
| resp, err := client.Delete(context.Background(), &pbresource.DeleteRequest{}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, resp) | ||
| } | ||
|
|
||
| func TestWatch_TODO(t *testing.T) { | ||
| server := NewServer(Config{}) | ||
| client := testClient(t, server) | ||
| wc, err := client.Watch(context.Background(), &pbresource.WatchRequest{}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, wc) | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
L1229 is the only new addition here outside of extracting code to
setupExternalGRPC(...)