-
Notifications
You must be signed in to change notification settings - Fork 108
Add client invocation for RestHublifetimeManager #2206
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
base: dev
Are you sure you want to change the base?
Conversation
src/Microsoft.Azure.SignalR.Management/RestHubLifetimeManager.cs
Outdated
Show resolved
Hide resolved
|
Don't forget to add e2e tests in |
|
@Y-Sindo E2E should wait for next release after the RT fixed is deployed right? After discussion will add it |
src/Microsoft.Azure.SignalR.Management/RestHubLifetimeManager.cs
Outdated
Show resolved
Hide resolved
| args, | ||
| async response => | ||
| { | ||
| responseContent = await response.Content.ReadAsStringAsync(cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use DeserializeAsync here directly
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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")] |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
Summary of the changes (Less than 80 chars)