Skip to content
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 configurable timeout #1103

Merged
merged 5 commits into from
Nov 17, 2020

Conversation

wanlwanl
Copy link
Member

Summary of the changes (Less than 80 chars)

  • Detail 1
  • Detail 2

Fixes #bugnumber (in this specific format)

@@ -15,9 +15,9 @@ namespace Microsoft.Azure.SignalR
{
internal class ServiceRouteHelper
{
public static async Task RedirectToService(HttpContext context, string hubName, IList<IAuthorizeData> authorizationData)
public static async Task RedirectToService(HttpContext context, Type hubType, IList<IAuthorizeData> authorizationData)
Copy link
Member

Choose a reason for hiding this comment

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

RedirectToService<T>?

Copy link
Member Author

Choose a reason for hiding this comment

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


namespace Microsoft.Azure.SignalR
{
internal interface INegotiateHandler
Copy link
Member

Choose a reason for hiding this comment

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

no need if not used in DI?

Copy link
Member Author

Choose a reason for hiding this comment

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

if (handshakeTimeout.Value.CompareTo(TimeSpan.Zero) <= 0 ||
handshakeTimeout.Value.CompareTo(Constants.Periods.MaxCustomHandshakeTimeout) > 0)
{
Log.FailToSetCustomHandshakeTimeout(logger, new ArgumentOutOfRangeException(nameof(handshakeTimeout)));
Copy link
Member

Choose a reason for hiding this comment

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

move the check to some validation when startup? otherwise customer gets such log for every request

@@ -66,7 +66,7 @@ private Endpoint CreateNegotiateEndpoint(RouteEndpoint routeEndpoint)
// Replaces the negotiate endpoint with one that does the service redirect
var routeEndpointBuilder = new RouteEndpointBuilder(async context =>
{
await ServiceRouteHelper.RedirectToService(context, hubMetadata.HubType.Name, null);
await ServiceRouteHelper.RedirectToService(context, hubMetadata.HubType, null);
Copy link
Member Author

Choose a reason for hiding this comment

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

@vicancy
About your comment , RedirectToService<T> can't be used due to the limit here - only Type is available

Copy link
Member

Choose a reason for hiding this comment

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

make CreateNegotiateEndpoint a generic method then? It only runs when start, while your approach creates the type for every request.

Copy link
Member Author

Choose a reason for hiding this comment

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

The CreateNegotiateEndpoint is used here, there's still no way to get the <THub> here.

The ApplyAsync is invoked on each negotiate request, while CreateNegotiateEndpoint needs the CandidateSet as a input parameter.

How about I change the ServiceRouteHelper to ServiceRouteHelper<Thub>, and DI to the gloabl service collection, and then get the service here and call the ServiceRouteHelper<THub>.RedirectToService() method? Then I don't need INegotiateHandler and Type of the hub any more.

@wanlwanl wanlwanl force-pushed the wanl/configurable-handshake-timeout branch from 042f46b to 0b3e8d6 Compare November 16, 2020 07:53
{
return type =>
{
var methodInfo = typeof(NegotiateMatcherPolicy).GetMethod(nameof(CreateNegotiateEndpointCore), BindingFlags.NonPublic | BindingFlags.Instance);
Copy link
Member

Choose a reason for hiding this comment

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

move it to outside of lamda, otherwise it is evaluated everytime.

Copy link
Member

Choose a reason for hiding this comment

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

I think this can be static

Copy link
Member Author

Choose a reason for hiding this comment

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

@vicancy updated

private Endpoint CreateNegotiateEndpoint(RouteEndpoint routeEndpoint)
private Func<Type, Endpoint> CreateNegotiateEndpoint(Type hubType, RouteEndpoint routeEndpoint)
{
var methodInfo = typeof(NegotiateMatcherPolicy).GetMethod(nameof(CreateNegotiateEndpointCore), BindingFlags.NonPublic | BindingFlags.Static);
Copy link
Member

Choose a reason for hiding this comment

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

this can be static readonly

@wanlwanl wanlwanl force-pushed the wanl/configurable-handshake-timeout branch from eb6a389 to a06216d Compare November 17, 2020 06:01
@wanlwanl wanlwanl merged commit 346970a into Azure:dev Nov 17, 2020
@wanlwanl wanlwanl deleted the wanl/configurable-handshake-timeout branch November 17, 2020 07:32
@vicancy vicancy mentioned this pull request Nov 19, 2020
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