Skip to content

[WebPubSub] Support invoke_event for webpubsub client - #45450

Open
Shiying Chen (MoChilia) wants to merge 13 commits into
Azure:mainfrom
MoChilia:invoke
Open

[WebPubSub] Support invoke_event for webpubsub client#45450
Shiying Chen (MoChilia) wants to merge 13 commits into
Azure:mainfrom
MoChilia:invoke

Conversation

@MoChilia

Copy link
Copy Markdown
Member

Description

Adds a preview invoke_event API to the Web PubSub client SDK, enabling request-response style communication with upstream event handlers. The client sends an invoke request, awaits the correlated invokeResponse, and returns the result, or raises InvocationError on failure/timeout.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings February 28, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a preview invoke_event request/response API to WebPubSubClient (sync + async), enabling upstream-event invocation with correlated invokeResponse handling, plus associated protocol/model updates and unit tests.

Changes:

  • Introduces new invoke/cancel/invokeResponse message models and invocation management helpers.
  • Adds invoke_event implementation to sync and async clients with correlation and error mapping via InvocationError.
  • Updates unit tests/protocol parsing and README documentation for the new preview feature.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_unit.py Adds protocol write/parse coverage for invoke/cancel/invokeResponse frames.
sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_invocation_manager.py Adds sync InvocationManager unit tests.
sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_invocation_manager_async.py Adds async InvocationManagerAsync unit tests.
sdk/webpubsub/azure-messaging-webpubsubclient/azure/messaging/webpubsubclient/models/_models.py Adds new invoke-related models, protocol parse/write support, and invocation managers/errors.
sdk/webpubsub/azure-messaging-webpubsubclient/azure/messaging/webpubsubclient/models/_enums.py Extends upstream message types to include invoke/cancelInvocation.
sdk/webpubsub/azure-messaging-webpubsubclient/azure/messaging/webpubsubclient/models/init.py Exposes new public result/error types and InvocationError.
sdk/webpubsub/azure-messaging-webpubsubclient/azure/messaging/webpubsubclient/aio/_client.py Implements async invoke_event, integrates invokeResponse dispatch and disconnect rejection.
sdk/webpubsub/azure-messaging-webpubsubclient/azure/messaging/webpubsubclient/_client.py Implements sync invoke_event, integrates invokeResponse dispatch and disconnect rejection.
sdk/webpubsub/azure-messaging-webpubsubclient/README.md Documents invoke_event usage (preview).

Comment thread sdk/webpubsub/azure-messaging-webpubsubclient/README.md
@github-actions

Copy link
Copy Markdown
Contributor

Hi Shiying Chen (@MoChilia). Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@github-actions github-actions Bot added the no-recent-activity There has been no recent activity on this issue. label May 15, 2026
@github-actions github-actions Bot removed the no-recent-activity There has been no recent activity on this issue. label May 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi Shiying Chen (@MoChilia). Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@github-actions github-actions Bot added the no-recent-activity There has been no recent activity on this issue. label Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 05:59
@github-actions github-actions Bot removed the no-recent-activity There has been no recent activity on this issue. label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Comment thread sdk/webpubsub/azure-messaging-webpubsubclient/README.md Outdated
Comment thread sdk/webpubsub/azure-messaging-webpubsubclient/tests/test_invoke_event_async.py Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 09:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread sdk/webpubsub/azure-messaging-webpubsubclient/CHANGELOG.md
Copilot AI review requested due to automatic review settings July 17, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.

Comment on lines +731 to +745
try:
await self._send_message(invoke_message, **kwargs)
except Exception as e:
invocation_error = (
e
if isinstance(e, InvocationError)
else InvocationError(
str(e) if str(e) else "Failed to send invocation message.",
invocation_id=invocation_id,
)
)
self._invocation_map.reject(invocation_id, invocation_error)
raise invocation_error from e

try:
Comment on lines +764 to +767
except Exception as e: # pylint: disable=broad-except
should_cancel = (
entry.result is None and isinstance(e, InvocationError) and e.error_detail is None
)
Comment on lines +803 to +805
return await func()
except InvocationError:
raise
Comment on lines +887 to +890
try:
return func()
except InvocationError:
raise
# Release History

## 1.1.1 (2024-XX-XX)
## 1.2.0 (Unreleased)
Comment on lines +11 to +13
import threading
import pytest
from unittest.mock import patch, MagicMock
Comment on lines +11 to +13
import asyncio
import pytest
from unittest.mock import patch, AsyncMock
def test_disconnect_rejects_pending_invocation(self):
"""Pending invocations are rejected when reject_all is called (simulating disconnect)."""
client = _make_client()
errors_received = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants