Skip to content

Conversation

@waltzofpearls
Copy link
Contributor

@waltzofpearls waltzofpearls commented Aug 11, 2025

Summary by CodeRabbit

  • New Features

    • Batched delivery of service data to devices to handle large service lists.
    • Progress indicators for batched syncs (batch numbering and total counts) so clients can show sync progress.
  • Performance Improvements

    • Faster, more reliable service synchronization for large deployments.
    • Reduced memory and network overhead during service updates, improving scalability and responsiveness.

@coderabbitai
Copy link

coderabbitai bot commented Aug 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new ServiceBatch message to device/device.proto and extends ServerToDeviceMessage’s oneof with a service_batch field, enabling batched delivery of repeated Service entries with batch metadata (total_services and batch_number).

Changes

Cohort / File(s) Summary of Changes
Proto: Device messaging
device/device.proto
Added message ServiceBatch { repeated Service services = 1; int32 total_services = 2; int32 batch_number = 3; }. Extended ServerToDeviceMessage oneof with ServiceBatch service_batch = 9; to support batched service delivery.

Sequence Diagram(s)

sequenceDiagram
  participant Server
  participant Device

  Server->>Device: ServerToDeviceMessage{ service_batch(batch 1) }
  Note right of Device: Receive services[], batch_number=1, total_services=N

  loop Subsequent batches
    Server->>Device: ServerToDeviceMessage{ service_batch(batch n) }
    Note right of Device: Accumulate services until total_services reached
  end

  Server->>Device: ServerToDeviceMessage{ service_batch(batch final) }
  Note right of Device: Verify total_services, process all services
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • adrianosela

Poem

I hop with packets in my paws so fleet,
Bundles of services packed neat.
Batch by batch I count and share,
Carrots—err—services handled with care.
A rabbit's cheer for tidy queueing treat! 🐇🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41be327 and 421358e.

⛔ Files ignored due to path filters (4)
  • device/device.pb.go is excluded by !**/*.pb.go
  • gen/kotlin/border0/device/v1/ServerToDeviceMessageKt.kt is excluded by !**/gen/**
  • gen/kotlin/border0/device/v1/ServiceBatchKt.kt is excluded by !**/gen/**
  • gen/swift/device.pb.swift is excluded by !**/gen/**
📒 Files selected for processing (1)
  • device/device.proto (2 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ME-4953-batch-resources-in-server-to-device-message

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.


message ServiceBatch {
repeated Service services = 1;
bool is_first_batch = 2; // Optional: for progress tracking
Copy link
Contributor

@adrianosela adrianosela Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use standard pagination terminology e.g. “ServicePage” message, with a pagination object e.g. items, has_next_page, page_size, page_number etc.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
device/device.proto (1)

39-39: Document service_batch usage, legacy fallback, and update handling

Adding service_batch = 9 to the existing oneof is wire-compatible, but we need to clarify its use and ensure any message-handling logic is updated:

– In device/device.proto (around line 39), add an inline comment:

-    ServiceBatch service_batch = 9;
+    // Batched services; only sent to agents advertising support for batching.
+    // Legacy agents continue receiving singular `service` messages.
+    ServiceBatch service_batch = 9;

– In your public API/docs (e.g. RELEASE_NOTES, README), spell out:
• When the server will emit service_batch vs service
• How legacy agents will fall back (capability negotiation, version gating, or server-side downgrade)
• That interleaving service and service_batch in a single session is only supported if explicitly handled.

– Scan any application code that inspects the ServerToDeviceMessage oneof (for example, switch messageCase in Swift/Kotlin or type-switch in Go) and confirm you handle the new serviceBatch branch appropriately.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d43bafb and 8402d37.

⛔ Files ignored due to path filters (4)
  • device/device.pb.go is excluded by !**/*.pb.go
  • gen/kotlin/border0/device/v1/ServerToDeviceMessageKt.kt is excluded by !**/gen/**
  • gen/kotlin/border0/device/v1/ServiceBatchKt.kt is excluded by !**/gen/**
  • gen/swift/device.pb.swift is excluded by !**/gen/**
📒 Files selected for processing (1)
  • device/device.proto (2 hunks)


message ServiceBatch {
repeated Service services = 1;
bool is_first_batch = 2; // Optional: for progress tracking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How/what-for do we use this field?

Copy link
Contributor

@adrianosela adrianosela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment regarding nomenclature. Otherwise lgtm

@waltzofpearls waltzofpearls force-pushed the ME-4953-batch-resources-in-server-to-device-message branch from 8402d37 to 41be327 Compare August 11, 2025 23:28
@waltzofpearls waltzofpearls force-pushed the ME-4953-batch-resources-in-server-to-device-message branch from 41be327 to 421358e Compare August 11, 2025 23:29
@waltzofpearls waltzofpearls merged commit fb077dd into main Aug 11, 2025
@adrianosela adrianosela deleted the ME-4953-batch-resources-in-server-to-device-message branch August 11, 2025 23:29
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.

3 participants