Refactor/nats subject change#356
Conversation
- improves reconnection triggering and handling - improves logging, introduces `log/slog`
- cleans up lot of junk code - improves logging with `log/slog`
…es logging - cleans up duplicated dispatch logic
- adds option to set SlogLogger as a global slog logger - grpc client auto-reconnect updates
Reviewer's Guide by SourceryThis pull request refactors the NATS subject handling, improves logging, and addresses several security vulnerabilities. The changes include updates to the NATS subject structure, enhanced logging using Tips
|
There was a problem hiding this comment.
Hey @nxtcoder17 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding integration tests to verify the new NATS subject naming convention works correctly across all affected components.
- The switch to
log/slogis a good improvement. Ensure all team members are familiar with the new logging patterns to maintain consistency in future development.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
|
|
||
| // ReceiveConsoleResourceUpdate implements messages.MessageDispatchServiceServer. | ||
| func (g *grpcServer) ReceiveConsoleResourceUpdate(ctx context.Context, msg *messages.ResourceUpdate) (*messages.Empty, error) { | ||
| func (g *grpcServer) ReceiveConsoleResourceUpdate(ctx context.Context, msg *messages.ResourceUpdate) (_ *messages.Empty, err error) { |
There was a problem hiding this comment.
suggestion: Consider wrapping errors for better context
The error handling has changed to return errors directly instead of wrapping them. While this simplifies the code, it might lead to loss of context. Consider using errors.Wrap or a similar method to preserve the error context, especially for non-trivial errors.
| func (g *grpcServer) ReceiveConsoleResourceUpdate(ctx context.Context, msg *messages.ResourceUpdate) (_ *messages.Empty, err error) { | |
| import "github.com/pkg/errors" | |
| func (g *grpcServer) ReceiveConsoleResourceUpdate(ctx context.Context, msg *messages.ResourceUpdate) (_ *messages.Empty, err error) { | |
| accountName, clusterName, err := g.validateAndDecodeFromGrpcContext(ctx, g.ev.TokenHashingSecret) | |
| if err != nil { | |
| return nil, errors.Wrap(err, "failed to validate and decode from gRPC context") | |
| } |
76098c0 to
9ae659f
Compare
- [Session Middleware Token Injection Vulnerability](https://github.com/kloudlite/api/security/dependabot/31) - [go-retryablehttp can leak basic auth credentials to log files](https://github.com/kloudlite/api/security/dependabot/32) - [gqlparser denial of service vulnerability via the parserDirectives function](https://github.com/kloudlite/api/security/dependabot/33)
9ae659f to
2d0684f
Compare
This PR introduces enhancements and fixes focusing on security, infrastructure improvements, and logging enhancements across various modules.
Security Updates
Infrastructure and Logging Improvements
Tenant-Agent Enhancements
log/slog.General Improvements
/_healthyfrom Fiber logs and added an option to setSlogLoggeras a global slog logger.Summary by Sourcery
This pull request introduces several enhancements and fixes focusing on security, infrastructure improvements, and logging enhancements across various modules. Key changes include addressing security vulnerabilities, refactoring NATS subject handling, improving logging, and updating the gRPC client for better auto-reconnect handling.
UUIDinpkg/functions/main.goto generate UUID strings of specified sizes.apps/infra,apps/message-office, andapps/console.log/slog./_healthyfrom Fiber logs and added an option to setSlogLoggeras a global slog logger.logging.Loggerwithslog.Loggerin multiple modules for improved logging capabilities.