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

Skip to content

Wrap JSONRPC messages with SessionMessage for metadata support #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 59 commits into from
May 2, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Apr 27, 2025

This PR introduces the SessionMessage type to encapsulate JSONRPC messages with metadata. This change enables clean separation between protocol messages and transport concerns.

Problem

Previously, memory streams propagated raw JSONRPCMessage objects, which made it difficult to pass transport-specific metadata (like resumption tokens or request correlation IDs) without violating the JSONRPC spec.

Proposed solution

Introduced a new SessionMessage type that wraps JSONRPCMessage with optional metadata:

  class SessionMessage:
      message: JSONRPCMessage
      metadata: MessageMetadata = None

With specialized metadata types:

  • ClientMessageMetadata: Contains resumption_token for client-side resumability and will contain additional fields needed for resumability
  • ServerMessageMetadata: Contains related_request_id for server-side request correlation

Changes

  • All memory streams now use SessionMessage instead of raw JSONRPCMessage
  • Session classes extract the underlying JSONRPC message for protocol operations
  • Transport implementations now can use metadata for transport-specific features:

NOTE: stacked on top of #587

bhosmer-ant
bhosmer-ant previously approved these changes May 1, 2025
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

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

LG - would it be worth adding any tests that exercise the new fields that might appear in SessionMessage? Could be that comes up in later PRs but just flagging [edit: ha nvm looking at 591 now]

dsp-ant
dsp-ant previously approved these changes May 2, 2025
Copy link
Member

@dsp-ant dsp-ant left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell. note that eventually we also want at that high level wrapper around JSONMessage some form of original request so that servers can introspect for example HTTP header. I had an early PR for this and merged it but it got reverted. Just something to think about as we starting to introduce that high level wrapper.

Base automatically changed from ihrpr/resumability-server to main May 2, 2025 13:10
@ihrpr ihrpr dismissed stale reviews from dsp-ant and bhosmer-ant May 2, 2025 13:10

The base branch was changed.

@ihrpr ihrpr enabled auto-merge (squash) May 2, 2025 13:28
@ihrpr ihrpr disabled auto-merge May 2, 2025 13:28
@ihrpr ihrpr merged commit da0cf22 into main May 2, 2025
9 checks passed
@ihrpr ihrpr deleted the ihrpr/memory-stream-item-type branch May 2, 2025 13:29
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.

3 participants