Skip to content

docs: document the query wait contract in builders + add example - #4

Open
DoubleTK wants to merge 3 commits into
mainfrom
tkenna/chore/document-query-contract
Open

docs: document the query wait contract in builders + add example#4
DoubleTK wants to merge 3 commits into
mainfrom
tkenna/chore/document-query-contract

Conversation

@DoubleTK

Copy link
Copy Markdown
Member

Summary

Makes the query wait contract discoverable from the builders instead of only from the sink's source. The builders documented Take/Wait loosely — TakeAll read as "take all within the duration" (no hint it never returns early), and Wait didn't mention that a zero/unset duration is the sink's 30s default — which made the long-poll easy to misuse (e.g. TakeAll + client-side retry polling, where a single call always blocks the full window).

Changes

  • Rewrote TakeFirst / TakeExact / TakeAll / Wait godoc across the span, log, and metric builders to state when each returns.
  • Added a package doc (builder/doc.go) with the Take/Duration contract and the canonical "wait for a specific signal" pattern (TakeFirst + filter + Wait).
  • Added a runnable godoc Example (builder/example_test.go) and a full push→query round-trip under examples/roundtrip/ — its own module so the OpenTelemetry SDK deps stay out of the library module.
  • Added a root README.md.

The contract (verified against the server)

Confirmed by reading OddDotNet/SignalList.cs (GetTakeCount + the QueryAsync loop):

Take Returns
TakeFirst (default) as soon as 1 match, else at Duration
TakeExact(n) as soon as n matches, else at Duration
TakeAll never early — always blocks the full Duration

Duration of zero or unset → 30s default (not "return immediately").

Notes

Test plan

  • go build ./..., go vet ./..., golangci-lint run ./... — clean
  • go test ./builder/... — passes, including the new Example
  • examples/roundtrip compiles (go build) and vets

🤖 Generated with Claude Code

https://claude.ai/code/session_01J2rAdqyGkWmhGLcfrRYxFy

DoubleTK and others added 2 commits July 15, 2026 11:20
The query builders documented Take/Wait loosely: TakeAll read as "take all
within the duration" with no hint it never returns early, and Wait did not note
that a zero or unset duration selects the sink's 30s default. That made the
long-poll semantics easy to misuse (e.g. TakeAll + client-side retry polling,
where a single call always blocks the full window).

- Rewrite the TakeFirst/TakeExact/TakeAll/Wait godoc across the span, log, and
  metric builders to state when each returns.
- Add a package doc (doc.go) with the Take/Duration contract and the canonical
  "wait for a specific signal" pattern (TakeFirst + filter + Wait).
- Add a runnable godoc example and a full push->query round-trip under
  examples/roundtrip (its own module, so the OTLP SDK deps stay out of the
  library module).

Verified against the OddDotNet server (SignalList.QueryAsync). Generated types
under gen/ pick up the matching proto comments on the next OddDotProto submodule
bump (see OddDotNet/OddDotProto#25).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2rAdqyGkWmhGLcfrRYxFy
The example binary was swept in by git add -A; remove it and add a .gitignore
so 'go build' output in examples/roundtrip stays untracked.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2rAdqyGkWmhGLcfrRYxFy
Bump the proto submodule to OddDotProto main (dbbb59c, #25 merged) and re-run
`make generate`. This pulls the newly-documented query API into the generated
Go: the proto doc comments now surface as godoc on the gen/ types and fields.

Regen is comments + gofmt realignment only — no protobuf-go/grpc API change,
no rawDesc/tag/field changes (verified). `go build ./...` passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0173DeQYX9USX5srXEeJUVqA
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.

1 participant