Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@raphael
Copy link
Member

@raphael raphael commented Sep 14, 2025

Problem

  • Service code emitted duplicate isEvent() marker methods when multiple streaming methods shared the same result type.
  • JSON-RPC SSE server stream generated duplicate "case *" entries when endpoints shared the same streaming result type.

Fix

  • codegen/service: Add dedupeByResult helper and use it in service.go.tpl so we only emit one Event marker per unique result type, and list unique Accepted types in the service-level Stream interface.
  • jsonrpc/codegen: Add dedupeBySSEEvent in SSE server codegen and use it in sse_server_stream_impl.go.tpl to generate a single switch case per unique SSE event type.

Tests

  • TestService_DedupEventMarkers: Asserts a single isEvent() marker for SharedEvent when two streaming methods share the type.
  • TestJSONRPCSSE_DedupEventTypes: Asserts a single switch case for SharedSSEEvent when two JSON-RPC SSE endpoints share the type.

Both tests fail without the fix and pass with it.

Notes

  • Changes are narrowly scoped to code generation; no behavior changes beyond duplicate emission removal.

…dd test\n\n- Add dedupeByResult helper and use it in service.go.tpl to avoid emitting\n duplicate is<Service>Event() marker methods when multiple streaming methods\n share the same result type.\n- Add StreamingDuplicateResultTypesDSL and TestService_DedupEventMarkers.\n\ncodegen(jsonrpc): dedupe SSE server switch cases for shared event types; add test\n\n- Add dedupeBySSEEvent FuncMap to SSE server codegen and use it in\n sse_server_stream_impl.go.tpl to prevent duplicate "case *<EventType>" entries\n when multiple endpoints share the same streaming result type.\n- Add JSONRPCSSEDuplicateEventDSL and TestJSONRPCSSE_DedupEventTypes.\n\nBoth tests fail without the fix and pass with it.
@raphael raphael changed the base branch from master to v3 September 14, 2025 20:14
@raphael raphael merged commit 699d114 into v3 Sep 14, 2025
@raphael raphael deleted the fix/dedupe-event-markers-jsonrpc-sse branch September 14, 2025 20:16
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