Skip to content

Port typed streaming IResult types from Marten.AspNetCore#35

Merged
jeremydmiller merged 2 commits intomainfrom
issue-32-streaming-result-types
Apr 21, 2026
Merged

Port typed streaming IResult types from Marten.AspNetCore#35
jeremydmiller merged 2 commits intomainfrom
issue-32-streaming-result-types

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Closes #32

Summary

Port the three typed streaming IResult types from Marten.AspNetCore to Polecat.AspNetCore:

  • StreamOne<T> — streams first matching document as JSON (200/404)
  • StreamMany<T> — streams JSON array of all matching documents (always 200, empty [] if none)
  • StreamAggregate<T> — streams latest event-sourced aggregate state (200/404)

All types implement IResult (for Minimal API dispatch) and IEndpointMetadataProvider (for OpenAPI metadata). Each exposes OnFoundStatus and ContentType as init-only properties.

Since Polecat doesn't have Marten's raw-JSON streaming path yet, these materialize documents via the regular query path then serialize with System.Text.Json. A later enhancement can swap to a true deserialize-free streaming path.

Test plan

  • stream_one_returns_200_with_document — hit case
  • stream_one_returns_404_when_not_found — miss case
  • stream_many_returns_200_with_json_array — multiple docs
  • stream_many_returns_empty_array_when_no_results — empty set
  • stream_aggregate_returns_200_with_aggregate — event-sourced hit
  • stream_aggregate_returns_404_for_unknown_id — event-sourced miss

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits April 21, 2026 08:42
Closes #32

Add three streaming IResult types to Polecat.AspNetCore for Minimal API
endpoints:

- StreamOne<T> — streams first matching document as JSON (200/404)
- StreamMany<T> — streams JSON array of documents (always 200)
- StreamAggregate<T> — streams latest event-sourced aggregate (200/404)

All types implement IResult and IEndpointMetadataProvider for OpenAPI.
Since Polecat doesn't have Marten's raw-JSON streaming path, documents
are materialized via the regular query path then serialized to the
response. A later enhancement can swap to true streaming once Polecat
grows one.

6 Alba integration tests covering: hit, 404, JSON array, empty array,
aggregate projection, and unknown aggregate ID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Restore EnableCorrelationId and EnableCausationId in Program.cs
  (removed accidentally, broke mcp_endpoint_tests assertions)
- Apply schema migration in streaming tests InitializeAsync so event
  store tables exist on fresh CI databases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 8c8885f into main Apr 21, 2026
30 checks passed
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.

Port typed streaming IResult types from Marten.AspNetCore

1 participant