Skip to content

feat(streaming): add streaming split utilities for gRPC message sizing#226

Merged
yushan8 merged 7 commits into
mainfrom
yushan/streaming-utils
Jul 21, 2026
Merged

feat(streaming): add streaming split utilities for gRPC message sizing#226
yushan8 merged 7 commits into
mainfrom
yushan/streaming-utils

Conversation

@yushan8

@yushan8 yushan8 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds internal/streaming package for splitting gRPC stream messages by wire size to stay under the per-message size limit. Also adds Size() to entity.OptimizedTarget for proto wire size estimation without importing protobuf.

Target graphs are split into bounded chunks before writing to storage. When the controller reads back, each Read() returns one pre-split chunk that fits in a single stream.Send(). Without splitting, large monorepos would exceed the gRPC message size limit.

Stack

  1. This PR (streaming utilities)
  2. feat(mapper): add entity-proto mappers #224 (entity-proto mappers, retargeted)
  3. refactor: replace proto serialization with JSON and migrate callsites #222 (storage JSON + entity migration)

Test plan

  • make build && make test && make gazelle

yushan8 and others added 3 commits July 20, 2026 11:19
Add internal/streaming package with:
- SplitBySize: generic function to split items into groups by wire size
- SplitMetadata: splits metadata maps into multiple messages
- SplitTargetGraph: splits targets and metadata into wire-safe response chunks

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add Size() method directly on entity.OptimizedTarget using packed
protobuf wire size calculation, so SplitTargetGraph works with plain
entity types throughout without converting to proto intermediaries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Inline the size-based grouping directly over the targets slice
instead of allocating a parallel []*OptimizedTarget pointer slice
to satisfy the Sizer generic constraint. For large monorepos with
hundreds of thousands of targets, this eliminates a needless
pointer-per-target allocation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8
yushan8 requested review from a team as code owners July 21, 2026 19:31
Comment thread entity/optimized_target.go Outdated
@yushan8
yushan8 marked this pull request as draft July 21, 2026 20:56
Move varintSize to an exported wire.VarintSize in a shared package so
both entity and internal/streaming import it instead of each maintaining
a copy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8
yushan8 marked this pull request as ready for review July 21, 2026 22:10
@yushan8
yushan8 merged commit a43f42b into main Jul 21, 2026
10 checks passed
yushan8 added a commit that referenced this pull request Jul 22, 2026
## Summary

Adds entity-proto mapping functions for the controller and orchestrator
layers:

- `internal/mapper/` — proto↔entity converters
(`GetTargetGraphResponseToProto`, `ChangedTargetsResponseToProto`,
`ProtoToGetTargetGraphRequest`, `ProtoToBuildDescription`,
`ToProtoError`)
- `mapper/` — top-level `ResultToTargetGraph` for converting
`targethasher.Result` into ID-mapped entity types (importable by
external consumers)

## Stack
1. #226 (streaming utilities)
2. **This PR** (entity-proto mappers)
3. #222 (storage JSON + entity migration)

## Test plan
- [x] `make build && make test && make gazelle`

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

2 participants