-
Notifications
You must be signed in to change notification settings - Fork 190
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
[SignalR] Add convenient POJOs. #774
Conversation
extensions/Worker.Extensions.SignalRService/src/Models/SignalRConnectionInfo.cs
Outdated
Show resolved
Hide resolved
/// <summary> | ||
/// The type of a group action. | ||
/// </summary> | ||
[JsonConverter(typeof(JsonStringEnumConverter))] |
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.
Question: Wonder how it will work if customer chooses to override JSON serializer to be JSON.NET.
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.
I have tried to change the JSON serializer to Newtonsoft.JSON as the code below and it still works. Maybe the conversion for bindings is not controlled by users. I am not sure about this, maybe we need a dotnet worker expert to confirm this.
class Program
{
static async Task Main(string[] args)
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(o =>
{
var settings = NewtonsoftJsonObjectSerializer.CreateJsonSerializerSettings();
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
settings.NullValueHandling = NullValueHandling.Ignore;
o.Serializer = new NewtonsoftJsonObjectSerializer(settings);
})
.Build();
await host.RunAsync();
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.
I have found that NewtonsoftJsonObjectSerializer
still works because Newtonsoft.Json
has built-in support for enum->string.
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 there any way to avoid customers changing the serialization and deserialization of some field of my POJO? For example, I want to make the enum SignalRGroupAction
serialized to string instead of number no matter how customers set their object serializer. But for the Arguments
field in SignalRInvocationContext
, SignalRMessageAction
, I want to let the customers to control the serialization/deserialization.
@fabiocav
I think what we need can be concluded to have independent JSON serialization/deserialization for these POJO so that I can control which fields should be serialized/deserialized with WorkerOptions.Serializaer
and which should not.
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 is not a blocker to merge this change. Something we should validate though.
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.
To add context. No, today, the configured serializer will be used by default. We're adding features that will give binding authors better control of this, but in the meantime, I agree with @kshyju , we don't need to block, but it might be something worth documenting.
extensions/Worker.Extensions.SignalRService/src/Models/SignalRInvocationContext.cs
Outdated
Show resolved
Hide resolved
|
||
/// <summary> | ||
/// The headers of request. | ||
/// Headers with duplicated key will be joined by comma. |
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.
will be joined by comma.
Or should we consider using <string,stringvalues>
as the type?
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.
I think it is a good idea, but deserialization is still a problem. If we customize the deserialization, how to avoid the customization changed by customers.
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.
Would be nice (not critical) to match how HttpRequestData
exposes this information for consistency, but that uses HttpHeadersCollection
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.
HttpHeadersCollection
is in a .NET 5 project, and cannot be referenced by .NET Standard 2.0 project.
extensions/Worker.Extensions.SignalRService/src/Models/SignalRInvocationContext.cs
Outdated
Show resolved
Hide resolved
extensions/Worker.Extensions.SignalRService/src/Models/SignalRMessageAction.cs
Outdated
Show resolved
Hide resolved
extensions/Worker.Extensions.SignalRService/src/Models/SignalRNegotiationContext.cs
Show resolved
Hide resolved
extensions/Worker.Extensions.SignalRService/src/Models/SignalRNegotiationContext.cs
Show resolved
Hide resolved
- Storage extensions moved to 5.0.0 | ||
- SignalR extensions added some convenient POJOs (PR #774) |
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.
We should also consider adding sample usage of this types in the extension samples.
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.
Currently the extension samples use package reference, so we cannot add new usages to the samples until they are released.
|
||
/// <summary> | ||
/// The headers of request. | ||
/// Headers with duplicated key will be joined by comma. |
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.
Would be nice (not critical) to match how HttpRequestData
exposes this information for consistency, but that uses HttpHeadersCollection
I think the PR is ready to be merged now. Thanks! |
Feel free to merge. |
I don't have the write access to merge currently. |
/check-enforcer evaluate |
Issue describing the changes in this PR
resolves partially #771
Pull request checklist
release_notes.md
I have tested it manually, but I don't know how to write unit tests or E2E tests for it.