Skip to content

Add client invocation for RestHublifetimeManager - #2206

Open
TD2106 wants to merge 10 commits into
Azure:devfrom
TD2106:duy/transient-ci
Open

Add client invocation for RestHublifetimeManager#2206
TD2106 wants to merge 10 commits into
Azure:devfrom
TD2106:duy/transient-ci

Conversation

@TD2106

@TD2106 TD2106 commented Jul 17, 2025

Copy link
Copy Markdown
Contributor

Summary of the changes (Less than 80 chars)

  • Add client invocation logic

@TD2106
TD2106 requested review from vicancy and vwxyzh July 17, 2025 09:39
Comment thread src/Microsoft.Azure.SignalR.Management/RestHubLifetimeManager.cs Outdated
@Y-Sindo

Y-Sindo commented Jul 28, 2025

Copy link
Copy Markdown
Member

Don't forget to add e2e tests in ServiceHubContextE2EFacts

@TD2106

TD2106 commented Aug 20, 2025

Copy link
Copy Markdown
Contributor Author

@Y-Sindo E2E should wait for next release after the RT fixed is deployed right?

After discussion will add it

Comment thread src/Microsoft.Azure.SignalR.Management/RestHubLifetimeManager.cs Outdated
args,
async response =>
{
responseContent = await response.Content.ReadAsStringAsync(cancellationToken);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use DeserializeAsync here directly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And RestClient already contains an ObjectSerializer, you can reuse that one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated by exposing the ObjectSerializer in the RestClient and using that.

throw new HubException(errorContent ?? "Unknown error in response");
}

return wrapper != null && wrapper.Result != null ? wrapper.Result : throw new HubException("Result not found in response");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is a null invocation result invalid?

// Ensure we have a response
if (!isSuccess)
{
throw new HubException(errorContent ?? "Unknown error in response");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's throw an AzureSignalRException to keep consistent with other functions.

#nullable enable
sealed class InvocationResponse<T>
{
[JsonPropertyName("result")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may not work if the object serializer is backed by Newtonsoft.Json.

{
await using var contentStream = await response.Content.ReadAsStreamAsync(cancellationToken);

var deserialized = await _restClient.ObjectSerializer.DeserializeAsync(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The ObjectSerializer should be used to deserialize the value of `InvocationResponse.Result“ only. How to deserialize the key "result" should be controlled by ourselves.


public ObjectSerializer ObjectSerializer => _payloadContentBuilder switch
{
JsonPayloadContentBuilder jsonBuilder => jsonBuilder.ObjectSerializer,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't work if the PayloadContentBuilder is not a JsonPayloadContentBuider. I'd suggest injecting IOptionsMonior<ServiceManagerOptions> into RestClient, using the ServiceManagerOptions.ObjectSerializer or providing a default one when ServiceManagerOptions.ObjectSerializer=null

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.

2 participants