♻️ Replace normal streams with JetStream
🐛 Fix pass order didn't handled successfully
This commit is contained in:
23
DysonNetwork.Shared/Stream/Streamer.cs
Normal file
23
DysonNetwork.Shared/Stream/Streamer.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using NATS.Client.JetStream;
|
||||
using NATS.Client.JetStream.Models;
|
||||
|
||||
namespace DysonNetwork.Shared.Stream;
|
||||
|
||||
public static class Streamer
|
||||
{
|
||||
public static async Task<INatsJSStream> EnsureStreamCreated(
|
||||
this INatsJSContext context,
|
||||
string stream,
|
||||
ICollection<string>? subjects
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await context.CreateStreamAsync(new StreamConfig(stream, subjects ?? []));
|
||||
}
|
||||
catch (NatsJSException)
|
||||
{
|
||||
return await context.GetStreamAsync(stream);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user