CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
45 lines
2.2 KiB
C#
45 lines
2.2 KiB
C#
using Chronos.Protocol;
|
|
using Chronos.Protocol.Client;
|
|
|
|
namespace Chronos.App.Server;
|
|
|
|
/// <summary>
|
|
/// What the Server section's job list needs from the signed-in server (owner review 5, #65): its jobs by state, one job,
|
|
/// pause, resume and cancel, and its events (<see cref="JobProgressEvent"/>, <see cref="JobStateEvent"/>). Owns its connection.
|
|
/// </summary>
|
|
public interface IServerJobsApi : IDisposable
|
|
{
|
|
/// <summary>A page of the server's jobs in <paramref name="state"/> (a wire name: running, paused…), newest first.</summary>
|
|
Task<Page<JobDto>> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken);
|
|
|
|
Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken);
|
|
|
|
Task<JobDto> PauseJobAsync(Guid id, CancellationToken cancellationToken);
|
|
|
|
Task<JobDto> ResumeJobAsync(Guid id, CancellationToken cancellationToken);
|
|
|
|
Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken);
|
|
|
|
/// <summary>Server events until cancelled or the socket closes.</summary>
|
|
IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken);
|
|
}
|
|
|
|
/// <summary><see cref="IServerJobsApi"/> over a signed-in <see cref="ChronosClient"/>, which it owns.</summary>
|
|
public sealed class ChronosServerJobsApi(ChronosClient client) : IServerJobsApi
|
|
{
|
|
public Task<Page<JobDto>> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken) =>
|
|
client.ListJobsAsync(state, null, cursor, cancellationToken);
|
|
|
|
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken) => client.GetJobAsync(id, cancellationToken);
|
|
|
|
public Task<JobDto> PauseJobAsync(Guid id, CancellationToken cancellationToken) => client.PauseJobAsync(id, cancellationToken);
|
|
|
|
public Task<JobDto> ResumeJobAsync(Guid id, CancellationToken cancellationToken) => client.ResumeJobAsync(id, cancellationToken);
|
|
|
|
public Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken) => client.CancelJobAsync(id, cancellationToken);
|
|
|
|
public IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken) => client.EventsAsync(cancellationToken);
|
|
|
|
public void Dispose() => client.Dispose();
|
|
}
|