Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 8908752

Browse files
Remaining sprocs (#41)
* Removed SPROCs * Update to latest packages
1 parent 7a24fbc commit 8908752

32 files changed

+589
-946
lines changed

.vscode/launch.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
{
2-
// Use IntelliSense to find out which attributes exist for C# debugging
3-
// Use hover for the description of the existing attributes
4-
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"name": ".NET Core Launch (console)",
9-
"type": "coreclr",
10-
"request": "launch",
11-
"preLaunchTask": "build",
12-
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/test/Orleans.CosmosDB.Tests/bin/Debug/netcoreapp3.0/Orleans.CosmosDB.Tests.dll",
14-
"args": [],
15-
"cwd": "${workspaceFolder}/test/Orleans.CosmosDB.Tests",
16-
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17-
"console": "internalConsole",
18-
"stopAtEntry": false
19-
},
20-
{
21-
"name": ".NET Core Attach",
22-
"type": "coreclr",
23-
"request": "attach",
24-
"processId": "${command:pickProcess}"
25-
}
26-
]
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/test/Orleans.CosmosDB.Tests/bin/Debug/netcoreapp3.1/Orleans.CosmosDB.Tests.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/test/Orleans.CosmosDB.Tests",
16+
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17+
"console": "internalConsole",
18+
"stopAtEntry": false
19+
},
20+
{
21+
"name": ".NET Core Attach",
22+
"type": "coreclr",
23+
"request": "attach",
24+
"processId": "${command:pickProcess}"
25+
}
26+
]
2727
}

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.0.100"
3+
"version": "3.1.100"
44
}
55
}

src/Orleans.Clustering.CosmosDB/CosmosDBGatewayListProvider.cs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Microsoft.Azure.Documents;
2-
using Microsoft.Azure.Documents.Client;
1+
using Microsoft.Azure.Cosmos;
2+
using Microsoft.Azure.Cosmos.Linq;
33
using Microsoft.Extensions.Logging;
44
using Microsoft.Extensions.Options;
55
using Orleans.Clustering.CosmosDB.Models;
@@ -21,7 +21,8 @@ internal class CosmosDBGatewayListProvider : IGatewayListProvider
2121
private readonly ILoggerFactory _loggerFactory;
2222
private readonly TimeSpan _maxStaleness;
2323
private readonly string _clusterId;
24-
private DocumentClient _dbClient;
24+
private CosmosClient _cosmos;
25+
private Container _container;
2526

2627
public TimeSpan MaxStaleness => this._maxStaleness;
2728

@@ -38,38 +39,40 @@ public CosmosDBGatewayListProvider(ILoggerFactory loggerFactory, IOptions<Cosmos
3839

3940
public async Task<IList<Uri>> GetGateways()
4041
{
41-
try
42-
{
43-
var spResponse = await this._dbClient.ExecuteStoredProcedureAsync<List<SiloEntity>>(
44-
UriFactory.CreateStoredProcedureUri(this._options.DB, this._options.Collection, SPROC),
45-
new RequestOptions { PartitionKey = new PartitionKey(this._clusterId) },
46-
this._clusterId);
42+
var query = this._container
43+
.GetItemLinqQueryable<SiloEntity>(requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey(this._clusterId) })
44+
.Where(g => g.EntityType == nameof(SiloEntity) &&
45+
g.Status == SiloStatus.Active &&
46+
g.ProxyPort.HasValue && g.ProxyPort.Value != 0).ToFeedIterator();
4747

48-
var uris = spResponse.Response.Select(ConvertToGatewayUri).ToList();
49-
return uris;
50-
}
51-
catch (Exception)
48+
var entities = new List<SiloEntity>();
49+
do
5250
{
53-
throw;
54-
}
51+
var items = await query.ReadNextAsync();
52+
entities.AddRange(items);
53+
} while (query.HasMoreResults);
54+
55+
var uris = entities.Select(ConvertToGatewayUri).ToList();
56+
return uris;
5557
}
5658

57-
public async Task InitializeGatewayListProvider()
59+
public Task InitializeGatewayListProvider()
5860
{
5961
if (this._options.Client != null)
6062
{
61-
this._dbClient = this._options.Client;
63+
this._cosmos = this._options.Client;
6264
}
6365
else
6466
{
65-
this._dbClient = new DocumentClient(new Uri(this._options.AccountEndpoint), this._options.AccountKey,
66-
new ConnectionPolicy
67-
{
68-
ConnectionMode = this._options.ConnectionMode,
69-
ConnectionProtocol = this._options.ConnectionProtocol
70-
});
67+
this._cosmos = new CosmosClient(
68+
this._options.AccountEndpoint,
69+
this._options.AccountKey,
70+
new CosmosClientOptions { ConnectionMode = this._options.ConnectionMode }
71+
);
7172
}
72-
await this._dbClient.OpenAsync();
73+
this._container = this._cosmos.GetDatabase(this._options.DB).GetContainer(this._options.Collection);
74+
75+
return Task.CompletedTask;
7376
}
7477

7578
private static Uri ConvertToGatewayUri(SiloEntity gateway)

0 commit comments

Comments
 (0)