-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Regenerate protobuf files #1359
Conversation
WalkthroughThe updates enhance the generated code for gRPC services and message handling, focusing on version increments for Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
Client->>Server: Send TestRequest
Server->>Client: Stream TestResponse
Client->>Server: Send more TestRequest
Server->>Client: Stream more TestResponse
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (34)
certificate-authority/pb/cert.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
certificate-authority/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
certificate-authority/pb/service.pb.gw.go
is excluded by!**/*.pb.gw.go
,!**/*.pb.gw.go
certificate-authority/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
certificate-authority/pb/signingRecords.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/cancelCommands.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/devices.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/events.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/getDevicesMetadata.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/getPendingCommands.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/hubConfiguration.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
grpc-gateway/pb/updateDeviceMetadata.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
identity-store/events/events.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
identity-store/pb/devices.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
identity-store/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
identity-store/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
m2m-oauth-server/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
m2m-oauth-server/pb/service.pb.gw.go
is excluded by!**/*.pb.gw.go
,!**/*.pb.gw.go
m2m-oauth-server/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/commands/commands.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/commands/resources.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/cqrs/aggregate/test/aggregate_test.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/cqrs/eventbus/pb/eventbus.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/events/events.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/service/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-aggregate/service/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-directory/pb/getLatestDeviceETags.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-directory/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
resource-directory/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
snippet-service/pb/service.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
snippet-service/pb/service.pb.gw.go
is excluded by!**/*.pb.gw.go
,!**/*.pb.gw.go
snippet-service/pb/service_grpc.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
Files selected for processing (2)
- pkg/net/grpc/stub.pb_test.go (4 hunks)
- pkg/net/grpc/stub_grpc.pb_test.go (6 hunks)
Files skipped from review due to trivial changes (1)
- pkg/net/grpc/stub.pb_test.go
Additional comments not posted (8)
pkg/net/grpc/stub_grpc.pb_test.go (8)
52-58
: Approved: Use of generics inTestStream
method implementation.The update to use
grpc.GenericClientStream[TestRequest, TestResponse]
ensures improved type safety while maintaining existing functionality.
62-63
: Acknowledged: Backward compatibility with type alias.The type alias for
StubService_TestStreamClient
ensures backward compatibility with existing code that references the prior non-generic stream type.
130-131
: Acknowledged: Backward compatibility with type alias.The type alias for
StubService_TestStreamServer
ensures backward compatibility with existing code that references the prior non-generic stream type.
127-127
: Approved: Use of generics in_StubService_TestStream_Handler
.The update to use
grpc.GenericServerStream[TestRequest, TestResponse]
ensures improved type safety while maintaining existing functionality.
98-104
: Approved: Embedding check inRegisterStubServiceServer
.The check ensures that
UnimplementedStubServiceServer
is embedded by value, preventing potential runtime panics.
18-19
: Acknowledged: gRPC version requirements.The assertions and version requirements ensure compatibility with gRPC-Go v1.64.0 or later.
31-31
: LGTM! Verify usage of the updatedTestStream
method.The change to use a generic
grpc.BidiStreamingClient[TestRequest, TestResponse]
enhances type safety and aligns with modern Go practices.Ensure that all usages of this method in the codebase are updated to accommodate the new signature.
Verification successful
All usages of the
TestStream
method have been updated successfully.The
TestStream
method is correctly used with the new generic signature across the codebase, including in test files. This confirms that the changes are consistent and properly integrated.
- Verified in
pkg/net/grpc/stub_grpc.pb_test.go
andpkg/net/grpc/interceptor_test.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all usages of the updated `TestStream` method in the codebase. # Test: Search for the `TestStream` method usage. Expect: Only occurrences with the new signature. rg --type go -A 5 'TestStream'Length of output: 6666
70-70
: LGTM! Verify implementations of the updatedTestStream
method.The change to use a generic
grpc.BidiStreamingServer[TestRequest, TestResponse]
enhances type safety and aligns with modern Go practices.Ensure that all implementations of this method in the codebase are updated to accommodate the new signature.
Verification successful
Implementations of
TestStream
method updatedThe
TestStream
method with the new generic signature is implemented in theUnimplementedStubServiceServer
struct withinpkg/net/grpc/stub_grpc.pb_test.go
. Ensure all other relevant implementations are similarly updated.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all implementations of the updated `TestStream` method in the codebase. # Test: Search for the `TestStream` method implementation. Expect: Only occurrences with the new signature. rg --type go -A 5 'func TestStream'Length of output: 414
Script:
#!/bin/bash # Description: Search for the `TestStream` method within interfaces or structs to verify its implementation. # Adjusted search pattern to look for `TestStream` in the context of interfaces or structs. ast-grep --lang go --pattern 'func ($_ TestStream)($_) $_'Length of output: 405
Script:
#!/bin/bash # Description: Refine search for the `TestStream` method in interfaces or structs to verify its implementation. # Use ripgrep to search for `TestStream` method definitions in the context of interfaces or structs. rg --type go 'TestStream\(grpc\.BidiStreamingServer\[TestRequest, TestResponse\]\)'Length of output: 334
With blockwise transfer enabled a data race in message.BodySize could occur. The issue is fixed by getting and caching of the message size before writing of the response message is started.
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: 0
Outside diff range, codebase verification and nitpick comments (2)
test/test.go (2)
1007-1029
: Ensure proper error handling inIsClosed
.The
IsClosed
method correctly attempts to bind to the address to check if the socket is closed. It usesrequire.NoError
for error handling, which is appropriate for test scenarios. However, consider usingassert.NoError
if you want the tests to continue running after a failure, providing more comprehensive test results.- require.NoError(t, err) + assert.NoError(t, err)
1033-1054
: Optimize socket closure check inCheckForClosedSockets
.The
CheckForClosedSockets
method effectively checks socket closure with a timeout. However, consider using a more descriptive variable name instead ofj
for the loop counter to improve readability.- for j := 0; j < 900; j++ { + for attempt := 0; attempt < 900; attempt++ {
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
test/helm/mock.plgd.cloud.yaml
is excluded by!**/*.yaml
test/helm/try.plgd.cloud.yaml
is excluded by!**/*.yaml
Files selected for processing (5)
- coap-gateway/service/service.go (3 hunks)
- coap-gateway/service/session.go (1 hunks)
- coap-gateway/test/test.go (1 hunks)
- pkg/opentelemetry/otelcoap/opentelemetry.go (3 hunks)
- test/test.go (1 hunks)
Additional comments not posted (12)
pkg/opentelemetry/otelcoap/opentelemetry.go (5)
31-33
: NewMessage
struct introduced.The new
Message
struct encapsulates theSize
attribute. This promotes encapsulation and type safety, which is a good practice.
61-65
: UpdatedEvent
method forMessageType
.The
Event
method now uses theMessage
struct. This change is consistent with the new struct-based approach and improves type safety.
94-94
: UpdatedMessageReceivedEvent
function.This function now accepts the
Message
struct, aligning with the new design. Ensure that all calls to this function are updated accordingly.Verification successful
Function calls to
MessageReceivedEvent
are correctly updated.All identified calls to the
MessageReceivedEvent
function have been updated to match the new signature with theMessage
struct. No further action is needed.
coap-gateway/service/service.go
: Call usesotelcoap.MakeMessage(req.Message)
.coap-gateway/service/session.go
: Call usesotelcoap.MakeMessage(resp)
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `MessageReceivedEvent` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 'MessageReceivedEvent\('Length of output: 1209
98-98
: UpdatedMessageSentEvent
function.This function now uses the
Message
struct. Ensure that all calls to this function are updated to match the new signature.Verification successful
Function calls to
MessageSentEvent
are updated.All identified calls to
MessageSentEvent
in the codebase have been updated to match the new signature using theMessage
struct. No outdated calls were found.
coap-gateway/service/session.go
:MessageSentEvent(ctx, otelcoap.MakeMessage(req))
coap-gateway/service/service.go
:MessageSentEvent(req.Context(), otelcoap.MakeMessage(resp))
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `MessageSentEvent` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 'MessageSentEvent\('Length of output: 1412
Line range hint
35-57
: Check error handling inMakeMessage
.The
MakeMessage
function computes the size of a message. Ensure that the error handling logic for theSize
method is appropriate and thatsize = 0
is a suitable fallback.coap-gateway/test/test.go (1)
75-82
: RefactorcheckForClosedSockets
to useListenSockets
.The refactoring simplifies the logic for checking closed sockets by using the
test.ListenSockets
type. This enhances readability and maintainability. Ensure thattest.ListenSockets
is correctly implemented and integrated.Verification successful
Refactoring Verified:
CheckForClosedSockets
is correctly integrated withListenSockets
.The method
CheckForClosedSockets
is implemented and used as intended, confirming the refactoring suggestion. The integration enhances readability and maintainability as expected.
ListenSockets
is defined and used intest/test.go
.CheckForClosedSockets
is utilized incoap-gateway/test/test.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation and integration of `test.ListenSockets`. # Test: Search for the `ListenSockets` type definition and its methods. Expect: Proper implementation and usage. rg --type go -A 5 'type ListenSockets'Length of output: 352
Script:
#!/bin/bash # Description: Search for usages of the `CheckForClosedSockets` method to verify its integration. # Test: Find all occurrences of `CheckForClosedSockets` to ensure it's used correctly. rg 'CheckForClosedSockets'Length of output: 167
coap-gateway/service/service.go (3)
345-349
: Enhance error handling inNew
function.The
New
function now handles errors fromcreateServices
by closing the NATS connection. This prevents resource leaks and improves robustness.
434-434
: UtilizeMakeMessage
inmakeCommandTask
.The
MakeMessage
function is used for message processing, ensuring consistency and maintainability. Verify thatMakeMessage
is correctly implemented and integrated.
418-418
: UtilizeMakeMessage
inprocessCommandTask
.The
MakeMessage
function is used for message processing, ensuring consistency and maintainability. Verify thatMakeMessage
is correctly implemented and integrated.Verification successful
MakeMessage
is correctly implemented and integrated. The function is consistently used across the codebase inMessageSentEvent
andMessageReceivedEvent
, ensuring proper message processing for telemetry purposes.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation and integration of `MakeMessage`. # Test: Search for the `MakeMessage` function definition and its usage. Expect: Proper implementation and usage. rg --type go -A 5 'func MakeMessage'Length of output: 452
Script:
#!/bin/bash # Description: Search for the usage of `MakeMessage` in the codebase to verify its integration and usage consistency. rg --type go 'MakeMessage'Length of output: 509
test/test.go (2)
1002-1005
: Encapsulate socket properties inListenSocket
.The
ListenSocket
type encapsulates the network type and address, which promotes clarity and reusability. This design aligns with best practices.
1031-1031
: UseListenSockets
to manage multiple sockets.The
ListenSockets
type, as a slice ofListenSocket
, provides a structured way to manage multiple sockets. This enhances the modularity and reusability of the code.coap-gateway/service/session.go (1)
222-230
: Enhance observability withotelcoap.MakeMessage
.The use of
otelcoap.MakeMessage
to wrap request and response messages improves telemetry and observability. Ensure that the wrapped messages contain all necessary attributes for effective monitoring.
Quality Gate passedIssues Measures |
No description provided.