Skip to content

refactor(container-runtime): Separate types LocalBatchMessage v. OutboundBatchMessage in Outbox and related code#24287

Merged
markfields merged 15 commits intomicrosoft:mainfrom
markfields:cr/batch-message-types
Apr 9, 2025
Merged

refactor(container-runtime): Separate types LocalBatchMessage v. OutboundBatchMessage in Outbox and related code#24287
markfields merged 15 commits intomicrosoft:mainfrom
markfields:cr/batch-message-types

Conversation

@markfields
Copy link
Copy Markdown
Member

@markfields markfields commented Apr 8, 2025

Description

This is almost entirely a glorified "rename", splitting the type BatchMessage into two cases: LocalBatchMessage and OutboundBatchMessage, converting between the two when necessary.

Context

As ops are accumulated into a batch in the ContainerRuntime, they're currently serialized immediately. However, we plan to keep those unserialized, and only stringify when virtualizing (grouping, compressing) in preparation to send to the server. See #24281.

This is the first step there. We should model pre/post virtualized batches differently because they are different. pre-virtualization batch messages are called LocalBatchMessage and post-virtualization are called OutboundBatchMessage.

Reviewer Guidance

The intention is to change no behavior with this PR. Here are the non-typing changes (that affect runtime code):

  • Renaming the property contents to serializedOp for the Local batch case
  • Shallow-copy the whole batch and each message in Outbox.virtualizeBatch to convert from LocalBatch to OutboundBatch.
    • This is where we copy serializedOp over to contents, which paves the way for serializedOp to stop being serialized in the next PR, which is the end goal here
  • Minor refactoring of createEmptyGroupedBatch to support both Local/Outbound forms

@github-actions github-actions Bot added area: runtime Runtime related issues base: main PRs targeted against main branch labels Apr 8, 2025
@markfields markfields marked this pull request as ready for review April 9, 2025 17:05
Copilot AI review requested due to automatic review settings April 9, 2025 17:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Comment thread packages/runtime/container-runtime/src/opLifecycle/definitions.ts Outdated
Copy link
Copy Markdown
Contributor

@kian-thompson kian-thompson left a comment

Choose a reason for hiding this comment

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

Love making typing more explicit

resubmittingBatchId: string,
referenceSequenceNumber: number,
): IBatch<[BatchMessage]> {
): { outboundBatch: OutboundSingletonBatch; placeholderMessage: OutboundBatchMessage } {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Not a huge fan of this return pattern since placeholderMessage is contained in outboundBatch as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah I see it too. But I didn't find a way to extract it that I was happy with. Empty Batches are janky, so I let it go.

Copy link
Copy Markdown
Contributor

@MarioJGMsoft MarioJGMsoft left a comment

Choose a reason for hiding this comment

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

LGTM!

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

Labels

area: runtime Runtime related issues base: main PRs targeted against main branch Feature_StagingMode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants