Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<ItemGroup>
<!-- Cratis -->
<PackageVersion Include="Cratis.Arc.Screenplay" Version="21.14.2" />
<PackageVersion Include="Cratis.Chronicle.Connections" Version="16.30.1" />
<PackageVersion Include="Cratis.Chronicle.Contracts" Version="16.30.1" />
<PackageVersion Include="Cratis.Chronicle.Connections" Version="16.36.3" />
<PackageVersion Include="Cratis.Chronicle.Contracts" Version="16.36.3" />
<PackageVersion Include="Cratis.Fundamentals" Version="7.17.1" />
<!-- Prologue -->
<PackageVersion Include="Cratis.Prologue.Configuration" Version="1.2.0" />
Expand All @@ -29,28 +29,28 @@
<PackageVersion Include="Grpc.Net.Client" Version="2.80.0" />
<PackageVersion Include="System.Text.Json" Version="10.0.10" />
<!-- Source Generator -->
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
<!-- Source reading — loading a solution or project into a Roslyn compilation for Screenplay generation. -->
<PackageVersion Include="Microsoft.Build.Locator" Version="1.11.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.9.0" />
<!-- Compile-time only: MSBuildLocator resolves the MSBuild assemblies from the installed .NET SDK at run time. -->
<PackageVersion Include="Microsoft.Build.Framework" Version="18.9.6" />
<PackageVersion Include="Microsoft.NET.StringTools" Version="18.9.6" />
<!-- Analysis -->
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" NoWarn="NU5104" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.15.0" />
<PackageVersion Include="Meziantou.Analyzer" Version="3.0.137" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="5.9.0" />
<!-- Transitive dependency overrides to address known vulnerabilities -->
<PackageVersion Include="Snappier" Version="1.3.1" />
<!-- Integration Testing -->
<PackageVersion Include="Testcontainers" Version="4.13.0" />
<PackageVersion Include="Testcontainers" Version="4.14.0" />
<!-- Testing -->
<PackageVersion Include="Cratis.Specifications" Version="4.0.0" />
<PackageVersion Include="Cratis.Specifications.XUnit" Version="4.0.0" />
<PackageVersion Include="Cratis.Chronicle.XUnit.Integration" Version="16.30.1" />
<PackageVersion Include="Cratis.Chronicle.XUnit.Integration" Version="16.36.3" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
Expand Down
21 changes: 21 additions & 0 deletions Integration/Chronicle/for_Diagnose/when_diagnosing_server.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using context = Cratis.Cli.Integration.Chronicle.for_Diagnose.when_diagnosing_server.context;

namespace Cratis.Cli.Integration.Chronicle.for_Diagnose;

[Collection(ChronicleCollection.Name)]
public class when_diagnosing_server(context context) : CliGiven<context>(context)
{
public class context : given.a_connected_cli
{
public CliCommandResult Result = null!;

async Task Because() => Result = await RunCliAsync("chronicle", "diagnose");
}

[Fact] void should_include_event_stores() => Context.Result.StandardOutput.ShouldContain("\"eventStores\": [");
[Fact] void should_include_the_system_event_store() => Context.Result.StandardOutput.ShouldContain("System");
[Fact] void should_have_no_errors() => Context.Result.StandardError.ShouldEqual(string.Empty);
}
2 changes: 1 addition & 1 deletion Source/Cli.Generators/Cli.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
<PackageReference Remove="System.Text.Json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="5.6.0" PrivateAssets="all" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class AddApplicationCommand : ChronicleCommand<AddApplicationSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, AddApplicationSettings settings, string format)
{
await services.Applications.Add(new AddApplication
await services.Applications.AddApplication(new AddApplicationRequest
{
Id = Guid.NewGuid().ToString(),
Id = Guid.NewGuid(),
ClientId = settings.ClientId,
ClientSecret = settings.ClientSecret
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Reactive.Linq;

namespace Cratis.Cli.Commands.Chronicle.Applications;

/// <summary>
Expand All @@ -15,7 +17,8 @@ public class ListApplicationsCommand : ChronicleCommand<EventStoreSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, EventStoreSettings settings, string format)
{
var applications = await services.Applications.GetAll();
var result = await services.Applications.AllApplications().FirstAsync();
var applications = result.Data ?? [];

OutputFormatter.Write(
format,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override async Task<int> ExecuteCommandAsync(IServices services, Remov
return ExitCodes.Success;
}

await services.Applications.Remove(new RemoveApplication
await services.Applications.RemoveApplication(new RemoveApplicationRequest
{
Id = settings.AppId
});
Expand Down
3 changes: 2 additions & 1 deletion Source/Cli/Commands/Chronicle/Diagnose/DiagnoseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ static async Task<DiagnoseData> Gather(IServices services, DiagnoseSettings sett
var eventStores = new List<string>();
try
{
eventStores = [.. await services.EventStores.GetEventStores()];
var result = await services.EventStores.AllEventStores();
eventStores = [.. result.Data ?? []];
}
catch { }

Expand Down
5 changes: 3 additions & 2 deletions Source/Cli/Commands/Chronicle/EventStoreSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static EventStoreSelectorResult TryPromptAndSave(
string? currentEventStore = null)
{
// Use Task.Run to execute the async connection and gRPC call in a clean thread-pool context.
// Calling ConnectSync (blocking) followed by GetEventStores().GetAwaiter().GetResult() from a
// Calling ConnectSync (blocking) followed by AllEventStores().GetAwaiter().GetResult() from a
// thread that itself was resumed from a blocked GetResult() call can cause deadlocks with the
// gRPC channel's internal completion machinery. Task.Run gives us a fresh context with no
// blocked thread in the chain.
Expand All @@ -60,7 +60,8 @@ public static EventStoreSelectorResult TryPromptAndSave(
eventStores = Task.Run(async () =>
{
using var client = await CliChronicleConnection.Connect(connectionString);
return (await client.Services.EventStores.GetEventStores()).ToList();
var result = await client.Services.EventStores.AllEventStores();
return (result.Data ?? []).ToList();
}).GetAwaiter().GetResult();
}
catch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class ListEventStoresCommand : ChronicleCommand<ChronicleSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, ChronicleSettings settings, string format)
{
var eventStores = await services.EventStores.GetEventStores();
var names = eventStores.ToList();
var eventStores = await services.EventStores.AllEventStores();
var names = (eventStores.Data ?? []).ToList();

OutputFormatter.Write(
format,
Expand Down
9 changes: 4 additions & 5 deletions Source/Cli/Commands/Chronicle/Jobs/GetJobCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ protected override async Task<int> ExecuteCommandAsync(IServices services, JobCo
return ExitCodes.ValidationError;
}

var result = await services.Jobs.GetJob(new GetJobRequest
var result = await services.Jobs.AllJobs(new AllJobsRequest
{
EventStore = settings.ResolveEventStore(),
Namespace = settings.ResolveNamespace(),
JobId = jobId
Namespace = settings.ResolveNamespace()
});

var job = result.Value0;
var job = result.Data?.SingleOrDefault(job => job.Id == jobId);

if (job is null)
{
Expand Down Expand Up @@ -65,7 +64,7 @@ protected override async Task<int> ExecuteCommandAsync(IServices services, JobCo
isCompleted = job.Progress?.IsCompleted,
message = job.Progress?.Message
},
steps = (steps ?? []).Select(s => new
steps = (steps.Data ?? []).Select(s => new
{
id = s.Id,
type = s.Type,
Expand Down
4 changes: 2 additions & 2 deletions Source/Cli/Commands/Chronicle/Jobs/ListJobsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class ListJobsCommand : ChronicleCommand<JobsSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, JobsSettings settings, string format)
{
var jobs = await services.Jobs.GetJobs(new GetJobsRequest
var jobs = await services.Jobs.AllJobs(new AllJobsRequest
{
EventStore = settings.ResolveEventStore(),
Namespace = settings.ResolveNamespace()
});

var jobList = (jobs ?? []).ToList();
var jobList = (jobs.Data ?? []).ToList();

OutputFormatter.Write(
format,
Expand Down
2 changes: 1 addition & 1 deletion Source/Cli/Commands/Chronicle/Jobs/ResumeJobCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override async Task<int> ExecuteCommandAsync(IServices services, JobCo
return ExitCodes.ValidationError;
}

await services.Jobs.Resume(new ResumeJob
await services.Jobs.ResumeJob(new ResumeJobRequest
{
EventStore = settings.ResolveEventStore(),
Namespace = settings.ResolveNamespace(),
Expand Down
2 changes: 1 addition & 1 deletion Source/Cli/Commands/Chronicle/Jobs/StopJobCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override async Task<int> ExecuteCommandAsync(IServices services, JobCo
return ExitCodes.ValidationError;
}

await services.Jobs.Stop(new StopJob
await services.Jobs.StopJob(new StopJobRequest
{
EventStore = settings.ResolveEventStore(),
Namespace = settings.ResolveNamespace(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Cratis.Chronicle.Contracts.Namespaces;

namespace Cratis.Cli.Commands.Chronicle.Namespaces;

/// <summary>
Expand All @@ -16,8 +18,8 @@ public class ListNamespacesCommand : ChronicleCommand<EventStoreSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, EventStoreSettings settings, string format)
{
var namespaces = await services.Namespaces.GetNamespaces(new GetNamespacesRequest { EventStore = settings.ResolveEventStore() });
var names = namespaces.ToList();
var namespaces = await services.Namespaces.AllNamespaces(new AllNamespacesRequest { EventStore = settings.ResolveEventStore() });
var names = (namespaces.Data ?? []).ToList();

OutputFormatter.Write(
format,
Expand Down
2 changes: 1 addition & 1 deletion Source/Cli/Commands/Chronicle/Users/AddUserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AddUserCommand : ChronicleCommand<AddUserSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, AddUserSettings settings, string format)
{
await services.Users.Add(new AddUser
await services.Users.AddUser(new AddUserRequest
{
UserId = Guid.NewGuid(),
Username = settings.Username,
Expand Down
5 changes: 4 additions & 1 deletion Source/Cli/Commands/Chronicle/Users/ListUsersCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Reactive.Linq;

namespace Cratis.Cli.Commands.Chronicle.Users;

/// <summary>
Expand All @@ -15,7 +17,8 @@ public class ListUsersCommand : ChronicleCommand<EventStoreSettings>
/// <inheritdoc/>
protected override async Task<int> ExecuteCommandAsync(IServices services, EventStoreSettings settings, string format)
{
var users = await services.Users.GetAll();
var result = await services.Users.AllUsers().FirstAsync();
var users = result.Data ?? [];

OutputFormatter.Write(
format,
Expand Down
2 changes: 1 addition & 1 deletion Source/Cli/Commands/Chronicle/Users/RemoveUserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override async Task<int> ExecuteCommandAsync(IServices services, Remov
return ExitCodes.Success;
}

await services.Users.Remove(new RemoveUser
await services.Users.RemoveUser(new RemoveUserRequest
{
UserId = settings.UserId
});
Expand Down
6 changes: 3 additions & 3 deletions Source/Cli/Commands/Chronicle/Workbench/WorkbenchData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public record WorkbenchData(
IReadOnlyList<string> EventStoreNames,
IReadOnlyList<ObserverInformation> Observers,
IReadOnlyList<FailedPartition> FailedPartitions,
IReadOnlyList<Job> Jobs,
IReadOnlyList<JobSummaryResponse> Jobs,
IReadOnlyList<Recommendation> Recommendations,
ulong? TailSequenceNumber,
DateTimeOffset CapturedAt,
Expand All @@ -76,8 +76,8 @@ public record WorkbenchData(
IReadOnlyList<string> ReadModelInstances,
int ReadModelInstancesTotalCount,
string? ReadModelInstancesError,
IReadOnlyList<Application> Applications,
IReadOnlyList<User> Users,
IReadOnlyList<ApplicationResponse> Applications,
IReadOnlyList<UserResponse> Users,
IReadOnlyList<Identity> Identities,
IReadOnlyList<EventStoreSubscriptionDefinition> EventStoreSubscriptions)
{
Expand Down
36 changes: 26 additions & 10 deletions Source/Cli/Commands/Chronicle/Workbench/WorkbenchDataService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Reactive.Linq;
using System.Text.Json;
using Cratis.Chronicle.Contracts.Identities;
using Cratis.Chronicle.Contracts.Jobs;
using Cratis.Chronicle.Contracts.Namespaces;
using Cratis.Chronicle.Contracts.Observation.EventStoreSubscriptions;
using Cratis.Cli.Commands.Chronicle.ReadModels;

Expand Down Expand Up @@ -165,7 +167,11 @@ public async Task<IReadOnlyList<AppendedEvent>> FetchNewEventsAsync(

async Task<IReadOnlyList<string>> FetchEventStoresAsync()
{
try { return [.. await services.EventStores.GetEventStores().ConfigureAwait(false)]; }
try
{
var result = await services.EventStores.AllEventStores().ConfigureAwait(false);
return [.. result.Data ?? []];
}
catch { return []; }
}

Expand Down Expand Up @@ -195,15 +201,16 @@ async Task<IReadOnlyList<FailedPartition>> FetchFailedPartitionsAsync(string eve
catch { return []; }
}

async Task<IReadOnlyList<Job>> FetchJobsAsync(string eventStore, string ns)
async Task<IReadOnlyList<JobSummaryResponse>> FetchJobsAsync(string eventStore, string ns)
{
try
{
return [.. (await services.Jobs.GetJobs(new GetJobsRequest
var result = await services.Jobs.AllJobs(new AllJobsRequest
{
EventStore = eventStore,
Namespace = ns
}).ConfigureAwait(false)) ?? []];
}).ConfigureAwait(false);
return [.. result.Data ?? []];
}
catch { return []; }
}
Expand Down Expand Up @@ -309,21 +316,30 @@ async Task<IReadOnlyList<string>> FetchNamespacesAsync(string eventStore)
{
try
{
return [.. await services.Namespaces.GetNamespaces(
new GetNamespacesRequest { EventStore = eventStore }).ConfigureAwait(false)];
var result = await services.Namespaces.AllNamespaces(
new AllNamespacesRequest { EventStore = eventStore }).ConfigureAwait(false);
return [.. result.Data ?? []];
}
catch { return []; }
}

async Task<IReadOnlyList<Application>> FetchApplicationsAsync()
async Task<IReadOnlyList<ApplicationResponse>> FetchApplicationsAsync()
{
try { return [.. await services.Applications.GetAll().ConfigureAwait(false) ?? []]; }
try
{
var result = await services.Applications.AllApplications().FirstAsync();
return [.. result.Data ?? []];
}
catch { return []; }
}

async Task<IReadOnlyList<User>> FetchUsersAsync()
async Task<IReadOnlyList<UserResponse>> FetchUsersAsync()
{
try { return [.. await services.Users.GetAll().ConfigureAwait(false) ?? []]; }
try
{
var result = await services.Users.AllUsers().FirstAsync();
return [.. result.Data ?? []];
}
catch { return []; }
}

Expand Down
Loading
Loading