Skip to content

Conversation

@TD2106
Copy link
Member

@TD2106 TD2106 commented Jul 17, 2025

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
@Y-Sindo
Copy link
Member

Y-Sindo commented Jul 28, 2025

Don't forget to add e2e tests in ServiceHubContextE2EFacts

@TD2106
Copy link
Member Author

TD2106 commented Aug 20, 2025

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

After discussion will add it

args,
async response =>
{
responseContent = await response.Content.ReadAsStringAsync(cancellationToken);
Copy link
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
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
Member 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
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
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
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
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
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