You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.4 KiB
C#

using DotNetCore.CAP;
namespace Ds.Module.MediatR
{
public class DistributedEventBus : IDistrbutedEventBus
{
private readonly ICapPublisher _capPublisher;
public DistributedEventBus(ICapPublisher capPublisher)
{
_capPublisher = capPublisher;
}
public void Publish<T>(string name, T? contentObj, string? callbackName = null) where T : IIntegrationEvent
{
_capPublisher.Publish(name, contentObj, callbackName);
}
public void Publish<T>(string name, T? contentObj, IDictionary<string, string?> headers) where T : IIntegrationEvent
{
_capPublisher.Publish(name, contentObj, headers);
}
public async Task PublishAsync<T>(string name, T? contentObj, string? callbackName = null, CancellationToken cancellationToken = default) where T : IIntegrationEvent
{
await _capPublisher.PublishAsync(name, contentObj, callbackName, cancellationToken);
}
public async Task PublishAsync<T>(string name, T? contentObj, IDictionary<string, string?> headers, CancellationToken cancellationToken = default) where T : IIntegrationEvent
{
await _capPublisher.PublishAsync(name, contentObj, headers, cancellationToken);
}
public void PublishDelay<T>(TimeSpan delayTime, string name, T? contentObj, IDictionary<string, string?> headers) where T : IIntegrationEvent
{
_capPublisher.PublishDelay(delayTime, name, contentObj, headers);
}
public void PublishDelay<T>(TimeSpan delayTime, string name, T? contentObj, string? callbackName = null) where T : IIntegrationEvent
{
_capPublisher.PublishDelay(delayTime, name, contentObj, callbackName);
}
public async Task PublishDelayAsync<T>(TimeSpan delayTime, string name, T? contentObj, IDictionary<string, string?> headers, CancellationToken cancellationToken = default) where T : IIntegrationEvent
{
await _capPublisher.PublishDelayAsync(delayTime, name, contentObj, headers, cancellationToken);
}
public async Task PublishDelayAsync<T>(TimeSpan delayTime, string name, T? contentObj, string? callbackName = null, CancellationToken cancellationToken = default) where T : IIntegrationEvent
{
await _capPublisher.PublishDelayAsync(delayTime, name, contentObj, callbackName, cancellationToken);
}
}
}