Compare commits
5 Commits
@@ -4,8 +4,14 @@ namespace TimetableDesigner.Backend.Events;
|
||||
|
||||
public abstract class EventQueue<TSelf> where TSelf : EventQueue<TSelf>
|
||||
{
|
||||
public abstract void Setup<TBuilder>(IServiceCollection services, TBuilder configuration)
|
||||
where TBuilder : EventQueueBuilder<TSelf>;
|
||||
|
||||
public abstract void Setup(IServiceCollection services, string connectionString);
|
||||
public void Setup<TBuilder>(IServiceCollection services, TBuilder configuration)
|
||||
where TBuilder : EventQueueBuilder<TSelf> =>
|
||||
Setup(services, configuration.GetConnectionParameters());
|
||||
|
||||
public void Setup(IServiceCollection services, string connectionString)
|
||||
=> Setup(services, connectionString.Split(';')
|
||||
.Select(x => x.Split('='))
|
||||
.ToDictionary(x => x.First(), x => x.Last()));
|
||||
|
||||
protected abstract void Setup(IServiceCollection services, IDictionary<string, string> connectionParameters);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
namespace TimetableDesigner.Backend.Events;
|
||||
|
||||
public abstract class EventQueueBuilder<TQueue> where TQueue : EventQueue<TQueue>;
|
||||
public abstract class EventQueueBuilder<TQueue> where TQueue : EventQueue<TQueue>
|
||||
{
|
||||
public abstract IDictionary<string, string> GetConnectionParameters();
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
namespace TimetableDesigner.Backend.Events;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace TimetableDesigner.Backend.Events;
|
||||
|
||||
public interface IEventQueuePublisher
|
||||
{
|
||||
public Task PublishAsync<T>(T data) where T : class;
|
||||
public sealed Task PublishAsync<T>(T data) where T : class => PublishAsync(JsonSerializer.Serialize(data), data.GetType());
|
||||
public Task PublishAsync(string data, Type dataType);
|
||||
}
|
||||
Reference in New Issue
Block a user