Skip to content

Commit

Permalink
Merge branch 'dev' into JialinXin-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
JialinXin authored Sep 14, 2023
2 parents 02c64f4 + 1ed0709 commit d2a2d27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion specs/ClientInvocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ Basically the process is similar and the major different is that service underst

### Transient Mode(TODO)

## Limitations

> NOTES
>
> * Service cached pending invocations for at most __10 minutes__ for memory concerns and will notify server when timeout.
> * Serverless is __NOT__ supporeted in the first stage.
> * ASPNET SignalR is __NOT__ supported.
> * Sharding is __NOT__ supported. Please use [Geo-Replication](https://learn.microsoft.com/azure/azure-signalr/howto-enable-geo-replication) for combined client invocation and large scale scenarios.
> * Sharding is __NOT__ fully supported yet. Please use [Geo-Replication](https://learn.microsoft.com/azure/azure-signalr/howto-enable-geo-replication) for combined client invocation and large scale scenarios. Also see [this](https://github.com/Azure/azure-signalr/pull/1828) for planning.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ internal IEnumerable<ServiceEndpoint> GetRoutedEndpoints(ServiceMessage message)
case CloseConnectionMessage closeConnectionMessage:
return _router.GetEndpointsForConnection(closeConnectionMessage.ConnectionId, endpoints);

case ClientInvocationMessage clientInvocationMessage:
return SingleOrNotSupported(_router.GetEndpointsForConnection(clientInvocationMessage.ConnectionId, endpoints), clientInvocationMessage);

case ServiceMappingMessage serviceMappingMessage:
return SingleOrNotSupported(_router.GetEndpointsForConnection(serviceMappingMessage.ConnectionId, endpoints), serviceMappingMessage);

case ServiceCompletionMessage serviceCompletionMessage:
return SingleOrNotSupported(_router.GetEndpointsForConnection(serviceCompletionMessage.ConnectionId, endpoints), serviceCompletionMessage);

default:
throw new NotSupportedException(message.GetType().Name);
}
Expand Down Expand Up @@ -416,6 +425,20 @@ private async Task WaitForClientsDisconnect(HubServiceEndpoint endpoint)
Log.TimeoutWaitingClientsDisconnect(_logger, endpoint.ToString(), (int)_scaleTimeout.TotalSeconds);
}

private IEnumerable<ServiceEndpoint> SingleOrNotSupported(IEnumerable<ServiceEndpoint> endpoints, ServiceMessage message)
{
var endpointCnt = endpoints.ToList().Count;
if (endpointCnt == 1)
{
return endpoints;
}
if (endpointCnt == 0)
{
throw new ArgumentException("Client invocation is not sent because no endpoint is returned from the endpoint router.");
}
throw new NotSupportedException("Client invocation to wait for multiple endpoints' results is not supported yet.");
}

internal static class Log
{
private static readonly Action<ILogger, string, Exception> _startingConnection =
Expand Down

0 comments on commit d2a2d27

Please sign in to comment.