feat: add jetstream api router and error envelope
This commit is contained in:
46
src/NATS.Server/JetStream/Api/JetStreamApiResponse.cs
Normal file
46
src/NATS.Server/JetStream/Api/JetStreamApiResponse.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
namespace NATS.Server.JetStream.Api;
|
||||
|
||||
public sealed class JetStreamApiResponse
|
||||
{
|
||||
public JetStreamApiError? Error { get; init; }
|
||||
public JetStreamStreamInfo? StreamInfo { get; init; }
|
||||
public JetStreamConsumerInfo? ConsumerInfo { get; init; }
|
||||
|
||||
public static JetStreamApiResponse NotFound(string subject) => new()
|
||||
{
|
||||
Error = new JetStreamApiError
|
||||
{
|
||||
Code = 404,
|
||||
Description = $"unknown api subject '{subject}'",
|
||||
},
|
||||
};
|
||||
|
||||
public static JetStreamApiResponse Ok() => new();
|
||||
}
|
||||
|
||||
public sealed class JetStreamStreamInfo
|
||||
{
|
||||
public required JetStreamStreamConfig Config { get; init; }
|
||||
public required JetStreamStreamState State { get; init; }
|
||||
}
|
||||
|
||||
public sealed class JetStreamConsumerInfo
|
||||
{
|
||||
public required JetStreamConsumerConfig Config { get; init; }
|
||||
}
|
||||
|
||||
public sealed class JetStreamStreamConfig
|
||||
{
|
||||
public string Name { get; init; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class JetStreamStreamState
|
||||
{
|
||||
public ulong Messages { get; init; }
|
||||
public ulong FirstSeq { get; init; }
|
||||
}
|
||||
|
||||
public sealed class JetStreamConsumerConfig
|
||||
{
|
||||
public string DurableName { get; init; } = string.Empty;
|
||||
}
|
||||
Reference in New Issue
Block a user