Skip to content

agents: add nsolid-version and add it to metadata#460

Open
santigimeno wants to merge 1 commit intonode-v24.x-nsolid-v6.xfrom
santi/nsolidversion
Open

agents: add nsolid-version and add it to metadata#460
santigimeno wants to merge 1 commit intonode-v24.x-nsolid-v6.xfrom
santi/nsolidversion

Conversation

@santigimeno
Copy link
Copy Markdown
Member

@santigimeno santigimeno commented Apr 29, 2026

Also, cache the metadata so it's not generated multiple times per different rpc's.
Finally, resolve having both nsolid-saas and nsolid-saas-token header name and settle for the first.

Summary by CodeRabbit

  • Refactor

    • Consolidated gRPC metadata handling into a centralized system that constructs and caches metadata once, then propagates it consistently across all gRPC streams and client operations, replacing previous pattern of passing individual string parameters.
    • Improved metadata refresh logic to ensure configuration changes properly update and propagate across all active gRPC connections.
  • Tests

    • Enhanced test validation to verify gRPC metadata is correctly passed through and accessible during operations.

Also, cache the metadata so it's not generated multiple times per
different rpc's.
Finally, resolve having both `nsolid-saas` and `nsolid-saas-token`
header name and settle for the first.
@santigimeno santigimeno requested a review from RafaelGSS April 29, 2026 18:30
@santigimeno santigimeno self-assigned this Apr 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6e892d4-d62f-432d-9fcf-f66f67a7a635

📥 Commits

Reviewing files that changed from the base of the PR and between f397c0b and 4d4f8ea.

📒 Files selected for processing (11)
  • agents/grpc/src/asset_stream.cc
  • agents/grpc/src/asset_stream.h
  • agents/grpc/src/command_stream.cc
  • agents/grpc/src/command_stream.h
  • agents/grpc/src/grpc_agent.cc
  • agents/grpc/src/grpc_agent.h
  • agents/grpc/src/grpc_client.cc
  • agents/grpc/src/grpc_client.h
  • test/agents/test-grpc-basic.mjs
  • test/common/nsolid-grpc-agent/index.js
  • test/common/nsolid-grpc-agent/server.mjs

Walkthrough

This PR refactors gRPC metadata handling by consolidating separate agent_id and saas string parameters into a centralized GrpcMetadata object. GrpcAgent now builds and caches metadata once, passing it to stream and client constructors via updated signatures. Test infrastructure is enhanced to validate metadata propagation.

Changes

Cohort / File(s) Summary
Stream Constructor Signatures
agents/grpc/src/asset_stream.h, agents/grpc/src/asset_stream.cc, agents/grpc/src/command_stream.h, agents/grpc/src/command_stream.cc
Both AssetStream and CommandStream constructors updated to accept a single GrpcMetadata reference instead of separate agent_id and saas strings. Metadata application delegated to GrpcClient::AddMetadata() helper.
gRPC Client Metadata Handling
agents/grpc/src/grpc_client.h, agents/grpc/src/grpc_client.cc
MakeClientContext signature changed to accept GrpcMetadata instead of individual string parameters. New AddMetadata static helper added to populate grpc::ClientContext with key/value pairs from metadata collection.
gRPC Agent Metadata Management
agents/grpc/src/grpc_agent.h, agents/grpc/src/grpc_agent.cc
GrpcAgent introduces cached rpc_metadata_ member, public rpc_metadata() accessor, and private BuildRpcMetadata() / RefreshRpcMetadata() methods. Metadata is built during initialization and refreshed on SaaS/gRPC configuration changes; cached metadata passed to all stream and client instantiations.
Test Infrastructure
test/common/nsolid-grpc-agent/index.js, test/common/nsolid-grpc-agent/server.mjs, test/agents/test-grpc-basic.mjs
Test server now forwards gRPC call metadata to parent process. New reusable checkRpcMetadata helper extracted for validating metadata structure and values. Basic gRPC test enhanced to verify metadata validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • RafaelGSS
  • juanarbol

Poem

🐰 Metadata consolidated, no strings attached,
One cache to rule them all, a pattern well-matched!
Where agent_id and saas once scattered about,
Now GrpcMetadata flows—no doubt!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main objective: adding nsolid-version and including it in metadata as the primary changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch santi/nsolidversion

Review rate limit: 3/5 reviews remaining, refill in 20 minutes and 28 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant