-
Notifications
You must be signed in to change notification settings - Fork 0
feat(service): add db version info to status response #35
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
base: main
Are you sure you want to change the base?
feat(service): add db version info to status response #35
Conversation
📝 WalkthroughWalkthroughThe PR makes the component service version-aware: server initialization now accepts a version string, service responses are enriched with DB and server version metadata, and DB version is read via a new models dependency. Changes
Sequence DiagramsequenceDiagram
participant Client
participant ComponentServer as Component Server
participant Database
Client->>ComponentServer: Request (SearchComponents / GetVersions)
activate ComponentServer
ComponentServer->>Database: Query component data
Database-->>ComponentServer: Component data
ComponentServer->>Database: getDBVersion()
Database-->>ComponentServer: DB schema/version
Note over ComponentServer: Enrich response with Server.version<br/>and Db.version
ComponentServer-->>Client: StatusResponse { Data, Status, Db{version}, Server{version} }
deactivate ComponentServer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
🤖 Fix all issues with AI agents
In `@go.mod`:
- Around line 13-16: The build is failing because go.sum is missing checksums
for the newly added modules (github.com/scanoss/go-grpc-helper,
github.com/scanoss/go-models, github.com/scanoss/go-purl-helper,
github.com/scanoss/papi); run `go mod tidy` in the module root to download and
verify those dependencies and regenerate go.sum, then commit the updated go.sum
so CI can pass.
🧹 Nitpick comments (1)
pkg/service/component_service.go (1)
175-186: Consider passing the request context for better observability.Using
context.Background()loses request tracing and cancellation signals. For consistency with observability practices and to allow the DB query to be cancelled if the request is cancelled, consider passing the context from the caller.♻️ Suggested refactor
-func (d componentServer) getDBVersion() *common.StatusResponse_DB { - dbVersion, err := d.dbVersionModel.GetCurrentVersion(context.Background()) +func (d componentServer) getDBVersion(ctx context.Context) *common.StatusResponse_DB { + dbVersion, err := d.dbVersionModel.GetCurrentVersion(ctx) if err != nil || len(dbVersion.SchemaVersion) == 0 { return nil } return &common.StatusResponse_DB{ SchemaVersion: dbVersion.SchemaVersion, CreatedAt: dbVersion.CreatedAt, } }Then update all call sites to pass
ctx:status.Db = d.getDBVersion(ctx)
| github.com/scanoss/go-grpc-helper v0.11.0 | ||
| github.com/scanoss/go-models v0.3.0 | ||
| github.com/scanoss/go-purl-helper v0.2.1 | ||
| github.com/scanoss/papi v0.21.0 | ||
| github.com/scanoss/papi v0.28.0 |
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.
Run go mod tidy to fix the build failure.
The pipeline is failing because the go.sum file is missing entries for the newly added dependencies. Run go mod tidy to regenerate the go.sum file with all required checksums.
🤖 Prompt for AI Agents
In `@go.mod` around lines 13 - 16, The build is failing because go.sum is missing
checksums for the newly added modules (github.com/scanoss/go-grpc-helper,
github.com/scanoss/go-models, github.com/scanoss/go-purl-helper,
github.com/scanoss/papi); run `go mod tidy` in the module root to download and
verify those dependencies and regenerate go.sum, then commit the updated go.sum
so CI can pass.
Summary
Dependencies
This PR depends on the following PRs being merged and tagged with their next minor version:
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.