-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add ApplicationName to options and use it to prefix the HubName #449
Conversation
Hi @steverash ,really appreciate your effort on improving the SDK. For this particular feature, we tend to follow the initial proposal in #348 to leverage the
Please just let us know if you have any concerns about the proposal. |
@vicancy I'm not familiar with the |
Yeah, from the implementation perspective, it is similar to |
@vicancy thanks for taking the time to review this. Is it just renaming hubPrefix to appName, but still implementing in the same way via the ServiceOptions? If so, I'm happy to go back through the code and do that? I can see the code around the ASP.NET version, but putting in the ServiceOptions seemed like a good fit and in keeping with the ASP.NET Core patterns. The ASP.NET/Owin code seems to work in a quite different way and does not utilise the ASP.NET Core Options pattern? I notice there is a seperate ASP.NET and Core ServiceOptions class that both implement IServiceEndpointOptions. I can see this would be confusing on the ASP.NET side as there would be 2 places in the Owin startup for AppName. At the moment even on the ASP.NET/Owin side, which has ApplicationName, I can't see that it actually provides any isolation of the Hubs? Is ApplicationName a work in progress in that respect? Also an important point for me is the ability to keep the signalr client routes the same whilst separating the Azure SignalR usage by the appName (hubPrefix). If you can confirm that it is the naming needing changing (HubPrefix -> AppName) and if you'd like me to proceed, I'm happy to update the PR tomorrow. |
Thanks @steverash, your points make sense.
How about updating the PR to:
cc @chenkennt @vwxyzh @davidfowl Any comments? |
@vicancy - I am happy with that plan. On a slight side issue, I've just noticed that the behaviour of ASP.NET and ASP.NET Core ServiceEndpointProvider differ. On ASP.NET the client endpoints don't include the hub query string parameter, but the ASP.NET Core ones do. Is this intentional or a bug? I'd noticed it whilst also finding that I'd failed to include the hubPrefix on ASP.NET endpoints. At the moment I've updated to only use on the server endpoints for ASP.NET. |
I've made the change to update it to ApplicationName. On the ASP.NET side, it was a struggle to reconcile the applicationName in the RunAzureSignalR function parameters and the new one in the options class. Given the Options class is shared between Core and ASP.NET Options.ApplicationName cannot be removed from ASP.NET easily. However, I've made the property set internal only for the ASP.NET Options.ApplicationName. I've also added an extra options property "UseHubNamePrefix" to ASP.NET. This means consumers will need to specifically opt into having the app name prefix applied on ASP.NET. I did this to preserve existing behaviour, as I was concerned that suddenly existing ASP.NET users will have hub names being unexpectedly prefixed. Not perfect, but hopefully the best option. |
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.
Looks cool, some minor comments
src/Microsoft.Azure.SignalR/EndpointProvider/DefaultServiceEndpointGenerator.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Azure.SignalR.AspNet/EndpointProvider/ServiceEndpointProvider.cs
Outdated
Show resolved
Hide resolved
I've made the changes suggested, and I've also changed the .NET Core project to remove the ApplicationName from the ServiceEndPoint and use the IOptions to supply the ApplicationName in the ServiceEndPointProvider. I think this is better and means ApplicationName is being provided more directly from the IOptions. |
src/Microsoft.Azure.SignalR.AspNet/EndpointProvider/ServiceEndpointProvider.cs
Outdated
Show resolved
Hide resolved
Apply |
Thank you for your work, I was actually waiting for exactly this feature and have been watching this PR for a while 😃 |
@TimVinkemeier The myget package should be the latest dev branch (we publish a new package when the dev branch changes), you can install you the package in myget. Just click the myget package link in this section, and follow the installation guide to install it. |
Added a HubPrefix property to the options class.
This allows it to be configured to prefix every HubName with a prefix and therefore allows applications to share the same Azure SignalR service without worrying about multiple applications having the same hub names.
#348