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

Open
wants to merge 1 commit into
base: ihrpr/resumability-server
Choose a base branch
from

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

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