-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Part3.2][Live-scale] add interfaces for scale ServiceEndpoint (#832)
* add interfaces for Scale ServiceEndpoint * add timeout check in ServiceEndpointManager when scale * improve timeout * better naming.
- Loading branch information
Showing
7 changed files
with
331 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 21 additions & 1 deletion
22
src/Microsoft.Azure.SignalR.Common/Endpoints/HubServiceEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.SignalR | ||
{ | ||
internal class HubServiceEndpoint : ServiceEndpoint | ||
{ | ||
public HubServiceEndpoint(string hub, IServiceEndpointProvider provider, ServiceEndpoint endpoint) : base(endpoint) | ||
private readonly TaskCompletionSource<bool> _scaleTcs; | ||
|
||
public HubServiceEndpoint( | ||
string hub, | ||
IServiceEndpointProvider provider, | ||
ServiceEndpoint endpoint, | ||
bool needScaleTcs = false | ||
) : base(endpoint) | ||
{ | ||
Hub = hub; | ||
Provider = provider; | ||
_scaleTcs = needScaleTcs ? new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously) : null; | ||
} | ||
|
||
internal HubServiceEndpoint() : base() { } | ||
|
||
public string Hub { get; } | ||
|
||
public IServiceEndpointProvider Provider { get; } | ||
|
||
/// <summary> | ||
/// Task waiting for HubServiceEndpoint turn ready when live add/remove endpoint | ||
/// </summary> | ||
public Task ScaleTask => _scaleTcs?.Task ?? Task.CompletedTask; | ||
|
||
public void CompleteScale() | ||
{ | ||
_scaleTcs?.TrySetResult(true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.