Merged incoming changes
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public const int QueueBounds = 100000;
|
||||
|
||||
public const string EmailServiceBus = nameof(EmailServiceBus);
|
||||
public const string GeneralServiceBus = nameof(GeneralServiceBus);
|
||||
public const string SalesServiceBus = nameof(SalesServiceBus);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public abstract class EventBusQueueBase
|
||||
{
|
||||
protected readonly Channel<IEvent> channel = Channel.CreateBounded<IEvent>(Constants.QueueBounds);
|
||||
|
||||
public ChannelWriter<IEvent> Outgoing => channel.Writer;
|
||||
|
||||
public ChannelReader<IEvent> Incoming => channel.Reader;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public interface IEvent : INotification
|
||||
{
|
||||
Guid Id { get; set; }
|
||||
|
||||
string Name { get; set; }
|
||||
|
||||
DateTimeOffset EnqueueAt { get; set; }
|
||||
|
||||
string CorrelationId { get; set; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public interface IEventBus
|
||||
{
|
||||
Task<Result> PublishAsync<TEvent>(TEvent notification, CancellationToken cancellationToken = default)
|
||||
where TEvent : class, IEvent;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public interface IEventBusQueue
|
||||
{
|
||||
ChannelWriter<IEvent> Outgoing { get; }
|
||||
|
||||
ChannelReader<IEvent> Incoming { get; }
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public interface IJobOrchestrator
|
||||
{
|
||||
Task SendAsync<TNotification>(TNotification notification, CancellationToken cancellationToken = default)
|
||||
where TNotification : IEvent;
|
||||
|
||||
Task ScheduleAsync<TNotification>(TNotification notification, string cronExpression, CancellationToken cancellationToken = default)
|
||||
where TNotification : IEvent;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
namespace LiteCharms.Abstractions;
|
||||
|
||||
public static class Timezones
|
||||
{
|
||||
public static TimeZoneInfo SouthAfricanTimeZone => TimeZoneInfo.FindSystemTimeZoneById("South Africa Standard Time");
|
||||
|
||||
public static string? LocaliseDateTime(this DateTime dateTime, TimeSpan offset) => offset.Hours > 0
|
||||
? $"{dateTime:yyyy-MM-ddTHH:mm:ss.fff}+{offset.Hours:00}:{offset.Minutes:00}"
|
||||
: $"{dateTime:yyyy-MM-ddTHH:mm:ss.fff}{offset.Hours:00}:{offset.Minutes:00}";
|
||||
|
||||
public static string? LocaliseDateTimeOffset(this DateTimeOffset dateTime, TimeSpan offset) => LocaliseDateTime(dateTime.DateTime, offset);
|
||||
|
||||
public static DateTimeOffset ToDateTimeWithTimeZone(this DateTime source, TimeZoneInfo? timezone = null)
|
||||
{
|
||||
DateTime sourceDateAdjusted = source.Kind != DateTimeKind.Utc
|
||||
? new(source.Ticks, DateTimeKind.Utc)
|
||||
: source;
|
||||
|
||||
var localised = timezone is null
|
||||
? new DateTimeOffset(sourceDateAdjusted.Ticks, SouthAfricanTimeZone.BaseUtcOffset).LocaliseDateTimeOffset(SouthAfricanTimeZone.BaseUtcOffset)
|
||||
: new DateTimeOffset(sourceDateAdjusted.Ticks, timezone!.BaseUtcOffset).LocaliseDateTimeOffset(timezone.BaseUtcOffset);
|
||||
|
||||
return DateTimeOffset.Parse(localised!);
|
||||
}
|
||||
|
||||
public static DateTimeOffset UtcNow(this TimeZoneInfo timezone) => ToDateTimeWithTimeZone(DateTime.Now, timezone);
|
||||
}
|
||||
Reference in New Issue
Block a user