Skip to content

feat(workbench): add batch ReadStructYAMLs RPC and client-side prefetching - #919

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ryulyrmynywq
Aug 27, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ryulyrmynywq

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR replaces the single ReadStructYAML RPC with a batch-capable ReadStructYAMLs RPC, adds client-side LRU caching and in-flight request deduplication, consolidates the diff smart component to fetch revisions in a single batch, and introduces StructYamlPrefetchService to prefetch surrounding revision and log struct YAMLs asynchronously.

Key Changes

  • RPC & Backend (proto, pkg/server):
    • Replaced single ReadStructYAML with ReadStructYAMLs accepting multiple struct IDs (up to 200 items per batch).
    • Adopted best-effort resolution (skipping non-existent/invalid struct IDs without failing the whole batch) and deduplicated IDs.
    • Added comprehensive table-driven tests for pkg/server/workbench and pkg/server/api/v1.
  • Frontend API Client (WorkbenchClientService):
    • Implemented readStructYAMLs:
      • In-memory LRU cache (capacity 2000).
      • Per-ID in-flight request deduplication to prevent duplicate RPC calls for concurrent requests.
      • Automatic request chunking into batches of 200 IDs.
      • Backward-compatible readStructYAML facade for single-ID callers.
    • Implemented prefetchStructYAMLs for fire-and-forget background caching with synchronous fast-path filtering.
  • Diff Smart Component (DiffSmartComponent):
    • Consolidated separate currentRevisionResource and previousRevisionResource into a single batch revisionYamlsResource.
  • Background Prefetching (StructYamlPrefetchService):
    • Automatically prefetches struct YAMLs in the background upon selection:
      • Timeline selection: Prefetches the first 50 chronological struct IDs from revisions and events.
      • Revision selection: Prefetches surrounding revisions on the same timeline (radius 20).
      • Log selection: Prefetches surrounding logs from the filtered logs list (radius 20).
    • Eagerly initialized on application bootstrap via provideAppInitializer.
  • Tests & Quality:
    • Full test coverage added for StructYamlPrefetchService, WorkbenchClientService batching & prefetching, and DiffSmartComponent.
    • All Go and Web unit tests pass, linters report 0 issues, Storybook builds successfully.
@kyasbal kyasbal added the type:feature New feature or request label Aug 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request refactors the single-item ReadStructYAML RPC into a batch-oriented ReadStructYAMLs service, updating the backend, protobuf definitions, and frontend client. The frontend now supports batching requests up to 200 items, in-flight request deduplication, and caching, alongside a new StructYamlPrefetchService that prefetches surrounding struct YAMLs in the background. Feedback on the changes points out a bug in the frontend client where checking if (yaml) on in-flight promise resolution incorrectly treats empty strings as falsy, preventing them from being cached or correctly aggregated.

…ching

- Replace single ReadStructYAML with batch ReadStructYAMLs RPC in proto and server.
- Support in-memory LRU caching, in-flight request deduplication, and automatic batching in WorkbenchClientService.
- Consolidate current/previous revision fetching into a single resource in DiffSmartComponent.
- Add StructYamlPrefetchService to prefetch surrounding revision and log struct YAMLs upon timeline, revision, and log selection.
@kyasbal
kyasbal force-pushed the push-ryulyrmynywq branch from 74c8bcd to 2dc19c6 Compare August 27, 2026 08:38
@kyasbal
kyasbal merged commit 6ee348f into GoogleCloudPlatform:main Aug 27, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-ryulyrmynywq branch August 27, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New feature or request

1 participant