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

Sam: Copy Projection read models to MongoDB for querying #614

Merged
merged 67 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
d984a04
Create new prerelease
jakhog Jan 25, 2022
c68c21e
Fix typo
jakhog Jan 25, 2022
6e4fd3d
Upgrade contracts
jakhog Jan 25, 2022
e91b59d
Create Runtime representation of new registration arguments.
jakhog Jan 25, 2022
f7f808d
Parse incoming registration arguments.
jakhog Jan 25, 2022
9254cfe
Converters for persisted copy specifications.
jakhog Jan 25, 2022
9fa5eb3
Provide default values for backwards compatability. Needs some specs.
jakhog Jan 25, 2022
f6fbf6f
Fix specs, and add new for when MongoDB copying has changed.
jakhog Jan 25, 2022
f45fb1e
Fix implementation of ProjectionDefinition comparer
jakhog Jan 25, 2022
c40b580
Try new code coverage reporting
jakhog Jan 26, 2022
cb227c9
Maybe fix the randomly failing tests
jakhog Jan 26, 2022
f6ed40a
Allow callbacks to be cancelled from inside the callback.
jakhog Jan 26, 2022
2a4edd1
Fix specs
jakhog Jan 26, 2022
b395daf
Fix find command for reporting coverage
jakhog Jan 26, 2022
1e69f61
Apply suggestions from code review
jakhog Jan 26, 2022
d59fc6a
Pass along properties recursively in Projection Comparer.
jakhog Jan 26, 2022
4d21076
Validate MongoDB collection name concept and add specs.
jakhog Jan 26, 2022
385cf2e
Merge pull request #615 from dolittle/copy-projections-interfaces
jakhog Jan 26, 2022
19f0d4c
Introduce IProjectionPersister that will both store in IProjectionSto…
jakhog Jan 27, 2022
abd509f
Introduce the IProjectionCopyStore that will be implemented for MongoDB
jakhog Jan 27, 2022
84d717d
Create ProjectionPersister and write specs for it.
jakhog Jan 27, 2022
3f2c91f
Implement ProjectionPersister, and add some metrics
jakhog Jan 27, 2022
06dcafc
Implement metrics for Projections.Stopre
jakhog Jan 27, 2022
86f3d48
Implement storage of read model copies in MongoDB
jakhog Jan 27, 2022
a9ad0b2
Add some specs for the MongoDB Copy Store
jakhog Jan 27, 2022
112a103
Throw when attempting to persist a projection that should not be pers…
jakhog Jan 28, 2022
cf78f75
Verify that ReplaceOne is only called once
jakhog Jan 28, 2022
97c467b
Merge pull request #616 from dolittle/implement-copy-store
jakhog Jan 28, 2022
5a6a0cf
Bind the MetricsCollector since it is not discovered.
jakhog Jan 28, 2022
9c13906
Merge pull request #617 from dolittle/bind-metrics-collector
jakhog Jan 28, 2022
aa993f7
Make metrics collectors Singleton
woksin Jan 28, 2022
dbd9b7c
Remove unneccesary bindings
woksin Jan 28, 2022
4af2c19
Merge pull request #618 from dolittle/make-metrics-collector-singleton
jakhog Jan 28, 2022
29a114f
Add specs for VerifyContractsCompatibility
jakhog Feb 1, 2022
f430d63
Fix implementation
jakhog Feb 1, 2022
7456029
Merge pull request #619 from dolittle/fix-contracts-compatibility
jakhog Feb 1, 2022
185ac71
Start testing out some conversions.
jakhog Feb 1, 2022
b7b600a
Fix bug where setting converted values in arrays changed the .Select …
jakhog Feb 1, 2022
d2be10f
Store conversions in ProjectionDefinition as array in MongoDB to allo…
jakhog Feb 1, 2022
616cecb
Start creating specs for ProjectionConverter
jakhog Feb 2, 2022
545e6fb
Plenty of specs to go around
jakhog Feb 2, 2022
9c46d0f
Merge pull request #620 from dolittle/conversions
woksin Feb 3, 2022
75eaca1
Upgrade contracts and fix implementations
jakhog Feb 3, 2022
95eef90
Fix specs for CompareProjectionDefinitionsForAllTenants.
jakhog Feb 3, 2022
fe9f6c2
Fix specs for Projections.Store.Copies.MongoDB
jakhog Feb 3, 2022
789e681
Add some more specs for CompareProjectionDefinitionsForAllTenants
jakhog Feb 3, 2022
db6ffe5
Introduce IPropertyRenamer
jakhog Feb 3, 2022
4256b77
Fix old specs
jakhog Feb 3, 2022
312b11a
Property renamer should return a new BsonDocument.
jakhog Feb 3, 2022
93f7548
Implement PropertyRenamer
jakhog Feb 3, 2022
7f6e113
Specs for PropertyRenamer
jakhog Feb 3, 2022
3a07a55
Merge pull request #621 from dolittle/renaming-and-new-contracts-stru…
woksin Feb 4, 2022
a4ba026
Add names to the discovered Runtime addresses
jakhog Feb 4, 2022
d3f7e0a
Sort the selection list alphabetically to make it a bit easier to fin…
jakhog Feb 4, 2022
b667666
Merge pull request #622 from dolittle/improve-cli-runtime-selector
woksin Feb 7, 2022
4745e6a
Upgrade contracts
jakhog Feb 8, 2022
bbb192c
Add the new conversion types
jakhog Feb 8, 2022
1bbf812
Add new conversions in the Runtime representations
jakhog Feb 8, 2022
14e2aed
Serialize the conversion type in projection-definitions as strings so…
jakhog Feb 8, 2022
aa576cd
Implement new conversions in ValueConverter
jakhog Feb 8, 2022
d14f405
Rename the property for the projection key in the copied read models …
jakhog Feb 8, 2022
6eac97b
Merge pull request #623 from dolittle/more-conversions
woksin Feb 8, 2022
9feebf9
Set GuidRepresentation for the MongoDB copy storage to Unspecified, t…
jakhog Feb 8, 2022
9ffc36f
Merge pull request #624 from dolittle/guid-serializer-fix
woksin Feb 8, 2022
be743ff
Use the released contracts version
woksin Feb 9, 2022
c2fe10e
Merge branch '7.6.0-sam' of github.com:dolittle/Runtime into 7.6.0-sam
woksin Feb 9, 2022
dbe91a9
Apply braces style for solution
woksin Feb 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release

env:
PRERELEASE_BRANCHES: gimli, bilbo # Comma separated list of prerelease branch names. 'alpha,rc, ...'
PRERELEASE_BRANCHES: sam # Comma separated list of prerelease branch names. 'alpha,rc, ...'

on:
pull_request:
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"
- name: Setup dotCover
run: dotnet tool install JetBrains.dotCover.GlobalTool -g
- name: Build
run: dotnet build --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release
- name: Create coverage report
run: dotnet dotcover test --dcXML=coverage.xml
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage"
- name: Report code coverage
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r CoverageReport.xml
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l CSharp $(find . -name coverage.cobertura.xml -printf '-r %p ')

build-prod-docker-image:
name: Build Production Docker Image
Expand Down
60 changes: 60 additions & 0 deletions Runtime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB", "Source\MongoDB\M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB", "Specifications\MongoDB\MongoDB.csproj", "{E64C0545-5A82-4E13-A394-70FF6855321D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Projections.Store", "Specifications\Projections.Store\Projections.Store.csproj", "{BAD65101-7ADD-4159-A991-D2FAF5326EAB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Projections.Store.Copies.MongoDB", "Source\Projections.Store.Copies.MongoDB\Projections.Store.Copies.MongoDB.csproj", "{9327DB02-0F1B-418B-8DB8-5CFD101F8489}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Projections.Store.Copies.MongoDB", "Specifications\Projections.Store.Copies.MongoDB\Projections.Store.Copies.MongoDB.csproj", "{D2173588-D49D-4015-9E42-7AB49EE50685}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform", "Specifications\Platform\Platform.csproj", "{BA66BF64-5F6F-4FF0-B887-0453945EB59D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1378,6 +1386,54 @@ Global
{E64C0545-5A82-4E13-A394-70FF6855321D}.Release|x64.Build.0 = Release|Any CPU
{E64C0545-5A82-4E13-A394-70FF6855321D}.Release|x86.ActiveCfg = Release|Any CPU
{E64C0545-5A82-4E13-A394-70FF6855321D}.Release|x86.Build.0 = Release|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Debug|x64.ActiveCfg = Debug|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Debug|x64.Build.0 = Debug|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Debug|x86.ActiveCfg = Debug|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Debug|x86.Build.0 = Debug|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Release|Any CPU.Build.0 = Release|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Release|x64.ActiveCfg = Release|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Release|x64.Build.0 = Release|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Release|x86.ActiveCfg = Release|Any CPU
{BAD65101-7ADD-4159-A991-D2FAF5326EAB}.Release|x86.Build.0 = Release|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Debug|x64.ActiveCfg = Debug|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Debug|x64.Build.0 = Debug|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Debug|x86.ActiveCfg = Debug|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Debug|x86.Build.0 = Debug|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Release|Any CPU.Build.0 = Release|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Release|x64.ActiveCfg = Release|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Release|x64.Build.0 = Release|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Release|x86.ActiveCfg = Release|Any CPU
{9327DB02-0F1B-418B-8DB8-5CFD101F8489}.Release|x86.Build.0 = Release|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Debug|x64.ActiveCfg = Debug|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Debug|x64.Build.0 = Debug|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Debug|x86.ActiveCfg = Debug|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Debug|x86.Build.0 = Debug|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Release|Any CPU.Build.0 = Release|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Release|x64.ActiveCfg = Release|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Release|x64.Build.0 = Release|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Release|x86.ActiveCfg = Release|Any CPU
{D2173588-D49D-4015-9E42-7AB49EE50685}.Release|x86.Build.0 = Release|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Debug|x64.ActiveCfg = Debug|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Debug|x64.Build.0 = Debug|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Debug|x86.ActiveCfg = Debug|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Debug|x86.Build.0 = Debug|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Release|Any CPU.Build.0 = Release|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Release|x64.ActiveCfg = Release|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Release|x64.Build.0 = Release|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Release|x86.ActiveCfg = Release|Any CPU
{BA66BF64-5F6F-4FF0-B887-0453945EB59D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{ACACF102-3A61-442F-B202-BDF92F6FD26A} = {562DC4C5-91AB-4280-B40C-A2E0C43AA21C}
Expand Down Expand Up @@ -1477,5 +1533,9 @@ Global
{73EC0F56-B3D6-4EDA-8C5A-8CB4A38F3CF3} = {95D3ED76-BB5F-442F-A99A-F48FF34FEDA6}
{8FEA8F72-60B1-495D-8A42-D0FD752F2272} = {562DC4C5-91AB-4280-B40C-A2E0C43AA21C}
{E64C0545-5A82-4E13-A394-70FF6855321D} = {95D3ED76-BB5F-442F-A99A-F48FF34FEDA6}
{BAD65101-7ADD-4159-A991-D2FAF5326EAB} = {95D3ED76-BB5F-442F-A99A-F48FF34FEDA6}
{9327DB02-0F1B-418B-8DB8-5CFD101F8489} = {562DC4C5-91AB-4280-B40C-A2E0C43AA21C}
{D2173588-D49D-4015-9E42-7AB49EE50685} = {95D3ED76-BB5F-442F-A99A-F48FF34FEDA6}
{BA66BF64-5F6F-4FF0-B887-0453945EB59D} = {95D3ED76-BB5F-442F-A99A-F48FF34FEDA6}
EndGlobalSection
EndGlobal
10 changes: 8 additions & 2 deletions Source/Assemblies/AssemblyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ void Populate()
{
provider.Libraries.ForEach(library =>
{
if (!_libraries.ContainsKey(library.Name)) _libraries.Add(library.Name, library);
if (!_libraries.ContainsKey(library.Name))
{
_libraries.Add(library.Name, library);
}
});

var assembliesToInclude = provider.Libraries.Where(
Expand All @@ -74,7 +77,10 @@ void ReapplyFilter()
var assembliesToRemove = _assemblies.Where(a =>
{
var name = a.GetName().Name;
if (!_libraries.ContainsKey(name)) return true;
if (!_libraries.ContainsKey(name))
{
return true;
}
return !_assemblyFilters.ShouldInclude(_libraries[name]);
}).ToArray();
assembliesToRemove.ForEach((a) => _assemblies.Remove(a));
Expand Down
18 changes: 12 additions & 6 deletions Source/CLI/Runtime/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dolittle.Runtime.ApplicationModel;
using Dolittle.Runtime.Artifacts;
using Dolittle.Runtime.CLI.Runtime.EventTypes;
using Dolittle.Runtime.Events;
Expand Down Expand Up @@ -60,7 +61,7 @@ protected IEnumerable<EventType> EventTypes
/// <returns>A <see cref="Try{TResult}"/> of type <see cref="MicroserviceAddress"/>.</returns>
protected async Task<Try<MicroserviceAddress>> SelectRuntimeToConnectTo(CommandLineApplication cli)
{
var addresses = (await _runtimes.GetAvailableRuntimeAddresses(Runtime)).ToList();
var addresses = (await _runtimes.GetAvailableRuntimeAddresses(Runtime)).OrderBy(ListTextFor).ToList();

if (!addresses.Any())
{
Expand All @@ -70,23 +71,22 @@ protected async Task<Try<MicroserviceAddress>> SelectRuntimeToConnectTo(CommandL

if (addresses.Count == 1)
{
return addresses[0];
return new MicroserviceAddress(addresses[0].Host, addresses[0].Port);
}

await cli.Out.WriteLineAsync("Found multiple available Runtimes, please select one of the following:");
while (true)
{
for (var i = 0; i < addresses.Count; i++)
{
var (host, port) = addresses[i];
await cli.Out.WriteLineAsync($"\t{i}) {host.Value}:{port.Value}");
await cli.Out.WriteLineAsync($"\t{i}) {ListTextFor(addresses[i])})");
}

var selection = Prompt.GetInt($"Select Runtime (0-{addresses.Count - 1}):");

if (selection >= 0 && selection < addresses.Count)
{
return addresses[selection];
return new MicroserviceAddress(addresses[selection].Host, addresses[selection].Port);
}

await cli.Out.WriteLineAsync("Invalid number, please select one of the following:");
Expand Down Expand Up @@ -115,4 +115,10 @@ protected string ResolveEventTypeIdentifier(ArtifactId eventTypeId)
? eventTypeId.Value.ToString()
: eventType.Alias;
}
}

static string ListTextFor(NamedRuntimeAddress address)
=> address.Name != MicroserviceName.NotSet && !string.IsNullOrWhiteSpace(address.Name)
? $"{address.Name} ({address.Host.Value}:{address.Port.Value})"
: $"{address.Host.Value}:{address.Port.Value}";

}
32 changes: 26 additions & 6 deletions Source/CLI/Runtime/DockerRuntimeAddresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Docker.DotNet;
using Docker.DotNet.Models;
using Dolittle.Runtime.ApplicationModel;
using Dolittle.Runtime.Microservices;
using Dolittle.Runtime.Services;

Expand All @@ -31,18 +32,18 @@ public DockerRuntimeAddresses(IDockerClient client)
}

/// <inheritdoc />
public async Task<IEnumerable<MicroserviceAddress>> Discover()
public async Task<IEnumerable<NamedRuntimeAddress>> Discover()
{
try
{
var containers = await _client.Containers.ListContainersAsync(new ContainersListParameters());
var runtimesWithExposedManagement =
containers.Where(IsRuntimeContainer).Where(HasManagementPortExposed);
return runtimesWithExposedManagement.Select(ManagmentPortAddress);
return runtimesWithExposedManagement.Select(ManagementPortAddress);
}
catch
{
return Array.Empty<MicroserviceAddress>();
return Array.Empty<NamedRuntimeAddress>();
}
}

Expand All @@ -52,9 +53,28 @@ static bool IsRuntimeContainer(ContainerListResponse container)
static bool HasManagementPortExposed(ContainerListResponse container)
=> container.Ports.Any(IsManagementPort);

static MicroserviceAddress ManagmentPortAddress(ContainerListResponse container)
=> new("localhost", container.Ports.First(IsManagementPort).PublicPort);
static NamedRuntimeAddress ManagementPortAddress(ContainerListResponse container)
=> new(
GetContainerName(container),
"localhost",
container.Ports.First(IsManagementPort).PublicPort);

static MicroserviceName GetContainerName(ContainerListResponse container)
{
if (container.Labels.TryGetValue("com.docker.compose.service", out var dockerComposeName))
{
return dockerComposeName;
}

var name = container.Names.FirstOrDefault(_ => !string.IsNullOrWhiteSpace(_));
if (name != null)
{
return name.TrimStart('/');
}

return MicroserviceName.NotSet;
}

static bool IsManagementPort(Port port)
=> port.Type == "tcp" && port.PrivatePort == EndpointsConfigurationDefaultProvider.DefaultManagementPort;
}
}
7 changes: 3 additions & 4 deletions Source/CLI/Runtime/ICanDiscoverRuntimeAddresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Collections.Generic;
using System.Threading.Tasks;
using Dolittle.Runtime.Microservices;

namespace Dolittle.Runtime.CLI.Runtime;

Expand All @@ -15,6 +14,6 @@ public interface ICanDiscoverRuntimeAddresses
/// <summary>
/// Discovers addresses of available Runtimes.
/// </summary>
/// <returns>An <see cref="IEnumerable{T}"/> of type <see cref="MicroserviceAddress"/> to available Runtimes.</returns>
Task<IEnumerable<MicroserviceAddress>> Discover();
}
/// <returns>An <see cref="IEnumerable{T}"/> of type <see cref="NamedRuntimeAddress"/> to available Runtimes.</returns>
Task<IEnumerable<NamedRuntimeAddress>> Discover();
}
6 changes: 3 additions & 3 deletions Source/CLI/Runtime/ICanLocateRuntimes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public interface ICanLocateRuntimes
/// Gets the addresses of Runtimes that are available to connect to, or the address provided in the argument.
/// </summary>
/// <param name="argument">An optional address provided to the CLI as an argument.</param>
/// <returns>An <see cref="IEnumerable{T}"/> of type <see cref="MicroserviceAddress"/> to available Runtimes.</returns>
Task<IEnumerable<MicroserviceAddress>> GetAvailableRuntimeAddresses(MicroserviceAddress argument = null);
}
/// <returns>An <see cref="IEnumerable{T}"/> of type <see cref="NamedRuntimeAddress"/> to available Runtimes.</returns>
Task<IEnumerable<NamedRuntimeAddress>> GetAvailableRuntimeAddresses(MicroserviceAddress argument = null);
}
18 changes: 18 additions & 0 deletions Source/CLI/Runtime/NamedRuntimeAddress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Dolittle.Runtime.ApplicationModel;
using Dolittle.Runtime.Microservices;

namespace Dolittle.Runtime.CLI.Runtime;

/// <summary>
/// Represents the address to a named instance of a Runtime for a Microservice.
/// </summary>
/// <param name="Name">The name of the Microservice.</param>
/// <param name="Host">The host of a microservice.</param>
/// <param name="Port">The host of a microservice.</param>
public record NamedRuntimeAddress(
MicroserviceName Name,
MicroserviceHost Host,
MicroservicePort Port);
8 changes: 5 additions & 3 deletions Source/CLI/Runtime/RuntimeLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dolittle.Runtime.ApplicationModel;
using Dolittle.Runtime.Microservices;
using Dolittle.Runtime.Services;

Expand All @@ -27,18 +28,19 @@ public RuntimeLocator(IEnumerable<ICanDiscoverRuntimeAddresses> addressProviders
}

/// <inheritdoc />
public async Task<IEnumerable<MicroserviceAddress>> GetAvailableRuntimeAddresses(MicroserviceAddress argument = null)
public async Task<IEnumerable<NamedRuntimeAddress>> GetAvailableRuntimeAddresses(MicroserviceAddress argument = null)
{
if (argument == null)
{
var results = await Task.WhenAll(_addressProviders.Select(_ => _.Discover()));
return results.SelectMany(_ => _);
}

var address = new MicroserviceAddress(
var address = new NamedRuntimeAddress(
MicroserviceName.NotSet,
string.IsNullOrWhiteSpace(argument.Host) ? DefaultRuntimeHost : argument.Host,
argument.Port == 0 ? EndpointsConfigurationDefaultProvider.DefaultManagementPort : argument.Port);

return new[] {address};
}
}
}
4 changes: 4 additions & 0 deletions Source/Collections/EnumerableEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ public bool Equals(IEnumerable<T> left, IEnumerable<T> right)
}

if (left == null || right == null)
{
return false;
}

var firstArray = left.ToArray();
var secondArray = right.ToArray();

if (firstArray.Length != secondArray.Length)
{
return false;
}

for (var i = 0; i < firstArray.Length; i++)
{
Expand Down
7 changes: 6 additions & 1 deletion Source/Collections/NullFreeDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ public TValue this[TKey key]
/// <inheritdoc/>
public void Add(TKey key, TValue value)
{
if (key == null) throw new ArgumentNullException(nameof(key));
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
if (value != null)
{
_dict[key] = value;
}
}

/// <inheritdoc/>
Expand Down
Loading