Skip to content

chore: refactor Watch API flags#2867

Draft
miparnisari wants to merge 3 commits intomainfrom
refactor-watch-flags
Draft

chore: refactor Watch API flags#2867
miparnisari wants to merge 3 commits intomainfrom
refactor-watch-flags

Conversation

@miparnisari
Copy link
Contributor

@miparnisari miparnisari commented Jan 30, 2026

Description

Avoid having to store each individual configuration for Watch API inside every datastore implementation.

Important files to review:

  • pkg/datastore/datastore.go - new structs and interface method
  • pkg/cmd/server/server.go - wiring flags down to WatchServer
  • internal/services/v1/watch.go - passing WatchServer configs to the datastore
  • pkg/cmd/datastore/datastore.go removal of custom datastore settings

Testing

  1. Added this to the first line of ds.Watch(): fmt.Printf("%+v\n", options)
  2. docker-compose up --build
  3. zed context set example localhost:50051 foobar --insecure
  4. zed import development/schema.yaml
  5. zed watch

CRDB

spicedb-1         | {Content:7 EmissionStrategy:0 CheckpointInterval:1s WatchBufferLength:128 WatchBufferWriteTimeout:1s WatchConnectTimeout:1s MaximumBufferedChangesByteSize:41800995}

On main:

spicedb-1         | watchBufferLength 1024
spicedb-1         | watchConnectTimeout 1s
spicedb-1         | CheckpointInterval 1s
spicedb-1         | watchBufferWriteTimeout 1s
spicedb-1         | watchBufferSize 43163130

Memory

{Content:7 EmissionStrategy:0 CheckpointInterval:1s WatchBufferLength:128 WatchBufferWriteTimeout:1s WatchConnectTimeout:1s MaximumBufferedChangesByteSize:38021520}

On main:

watch buffer length: 1024 (the flag's default)
watch buffer write timeout: 100ms (the datastore's default)

Spanner

{Content:7 EmissionStrategy:0 CheckpointInterval:100ms WatchBufferLength:128 WatchBufferWriteTimeout:1s WatchConnectTimeout:1s MaximumBufferedChangesByteSize:399708510}

On main:

spicedb-1         | watchBufferLength 1024
spicedb-1         | heartbeatInterval 1s
spicedb-1         | watchBufferWriteTimeout 1s
spicedb-1         | watchBufferSize 593989155
spicedb-1         | heartbeat interval: 1s

References

Closes #2861

@github-actions github-actions bot added area/cli Affects the command line area/api v1 Affects the v1 API area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Jan 30, 2026
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 84.12698% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.89%. Comparing base (fa1d7f4) to head (c96674a).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/datastore/datastore.go 64.39% 24 Missing and 2 partials ⚠️
...nal/datastore/proxy/schemacaching/watchingcache.go 64.71% 5 Missing and 1 partial ⚠️
internal/services/v1/watch.go 82.36% 2 Missing and 1 partial ⚠️
internal/datastore/proxy/counting.go 0.00% 2 Missing ⚠️
internal/datastore/proxy/singleflight.go 0.00% 2 Missing ⚠️
pkg/cmd/testserver/testserver.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2867      +/-   ##
==========================================
+ Coverage   74.83%   74.89%   +0.06%     
==========================================
  Files         484      484              
  Lines       57789    57900     +111     
==========================================
+ Hits        43242    43359     +117     
+ Misses      11532    11518      -14     
- Partials     3015     3023       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@miparnisari miparnisari force-pushed the refactor-watch-flags branch 3 times, most recently from cf1ba27 to 5809bb1 Compare February 2, 2026 01:40
@miparnisari miparnisari changed the title chore: refactor Watch API flags (close #2861) chore: refactor Watch API flags Feb 2, 2026
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI all this code got moved to avoid circular imports


// Watch notifies the caller about changes to the datastore, based on the specified options.
//
// The specified options must be built and validated by the caller.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is important

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

Labels

area/api v1 Affects the v1 API area/cli Affects the command line area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor passing down of watch flags to avoid bugs

1 participant