-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dev #16
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe updates introduce new message types and RPC methods in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant WebApp
participant OrderClientHandler
participant OrderService
participant OrderRepo
User->>WebApp: Request Order Cancellation
WebApp->>OrderClientHandler: DELETE /orders/{id}/cancel
OrderClientHandler->>OrderService: CancelPendingOrder(CancelPendingOrderRequest)
OrderService->>OrderRepo: CancelOrder(orderId)
OrderRepo-->>OrderService: Success/Error
OrderService-->>OrderClientHandler: CancelPendingOrderResponse
OrderClientHandler-->>User: Confirmation Message
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: 1
Outside diff range, codebase verification and nitpick comments (7)
common/proto/orders/orders.proto (1)
60-61
: Consider adding fields toCancelPendingOrderRequest
.The
CancelPendingOrderRequest
message is currently empty. Consider adding fields if additional data is required for order cancellation.gateway/users_client_handler.go (2)
120-133
: Ensure comprehensive error handling inResendOTP
.The
ResendOTP
function includes basic error handling. Consider adding more specific error messages or logging for better debugging.
136-150
: Ensure comprehensive error handling inGetWalletBalance
.The
GetWalletBalance
function includes basic error handling. Consider adding more specific error messages or logging for better debugging.users/grpc_server_handler.go (4)
243-244
: Enhance error logging with more context.Providing more context in error logs can help with debugging. Include relevant information like the email address or operation being performed.
Apply this diff to improve error logging:
log.Println("Generate Code Failed for email:", email, "Error:", err) log.Println("Failed to marshal data for email:", email, "Error:", err) log.Println("Failed to publish a message for email:", email, "Error:", err)Also applies to: 270-271, 281-282
294-295
: Add error logging for user retrieval failure.Logging errors when a user is not found can help with monitoring and debugging.
Apply this diff to add error logging:
if err!= nil { + log.Printf("User not found for ID: %d, Error: %v", userId, err) return nil, errors.New("user not found") }
Line range hint
212-213
: Improve error logging for OTP retrieval failure.Adding more context to error logs can aid in debugging.
Apply this diff to improve error logging:
if err!= nil { + log.Printf("Failed to get cached OTP for email: %s, Error: %v", email, err) return nil, errors.New("failed to get cached otp") }
Line range hint
226-228
: Handle wallet credit errors more effectively.Currently, the error is logged but not returned. Consider returning the error to the caller for better error handling.
Apply this diff to handle the error more effectively:
if err!= nil { log.Println(err.Error()) + return nil, errors.New("failed to credit user wallet") }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (4)
common/proto/orders/orders.pb.go
is excluded by!**/*.pb.go
common/proto/orders/orders_grpc.pb.go
is excluded by!**/*.pb.go
common/proto/users/users.pb.go
is excluded by!**/*.pb.go
common/proto/users/users_grpc.pb.go
is excluded by!**/*.pb.go
Files selected for processing (4)
- common/proto/orders/orders.proto (1 hunks)
- common/proto/users/users.proto (2 hunks)
- gateway/users_client_handler.go (2 hunks)
- users/grpc_server_handler.go (1 hunks)
Additional comments not posted (8)
common/proto/orders/orders.proto (2)
62-64
: EnsureCancelPendingOrderResponse
message is sufficient.The
CancelPendingOrderResponse
contains only amessage
field. Ensure this is sufficient for the response or consider adding more fields if needed.
73-73
: RPC methodCancelPendingOrder
looks good.The addition of the
CancelPendingOrder
RPC method enhances the service's functionality.common/proto/users/users.proto (5)
74-76
: Verify the necessity ofOTPResendPayload
fields.The
OTPResendPayload
contains only an
78-80
: EnsureOTPResendResponse
message is sufficient.The
OTPResendResponse
contains only amessage
field. Ensure this is sufficient for the response or consider adding more fields if needed.
82-84
: Verify the necessity ofWalletBalanceRequest
fields.The
WalletBalanceRequest
contains only auser_id
field. Ensure this is sufficient for the wallet balance inquiry functionality.
86-89
: EnsureWalletBalanceResponse
message is sufficient.The
WalletBalanceResponse
containsbalance
andmessage
fields. Ensure this is sufficient for the response or consider adding more fields if needed.
99-100
: RPC methodsResendOTP
andGetWalletBalance
look good.The addition of the
ResendOTP
andGetWalletBalance
RPC methods enhances the service's functionality.gateway/users_client_handler.go (1)
30-31
: New routes for OTP resending and wallet balance inquiries are well-placed.The new routes for OTP resending and wallet balance inquiries are correctly registered in the router.
log.Fatalf("Failed to declare queue: %v", err) |
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.
Avoid using log.Fatalf
in server code.
Using log.Fatalf
will terminate the program if the queue declaration fails. Consider returning an error instead to allow the server to continue running.
Apply this diff to handle the error without terminating the program:
if err!= nil {
- log.Fatalf("Failed to declare queue: %v", err)
+ log.Printf("Failed to declare queue: %v", err)
+ return nil, errors.New("failed to declare queue")
}
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.
if err!= nil { | |
log.Fatalf("Failed to declare queue: %v", err) | |
if err!= nil { | |
log.Printf("Failed to declare queue: %v", err) | |
return nil, errors.New("failed to declare queue") |
Summary by CodeRabbit
New Features
Bug Fixes
Documentation