-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently only EnqueueTopic is supported.
Proposal:
public interface ITopicPublisher
{
...
void ScheduleTopic<T>(string topic, T data, TimeSpan delay);
void ScheduleTopic<T>(string topic, T data, DateTimeOffset enqueueAt);
}
public class TopicPublisher : ITopicPublisher
{
...
public void ScheduleTopic<T>(string topic, T data, TimeSpan delay)
{
BackgroundJob.Schedule(() => DispatchTopic(topic, data), delay);
}
public void ScheduleTopic<T>(string topic, T data, DateTimeOffset enqueueAt)
{
BackgroundJob.Schedule(() => DispatchTopic(topic, data), enqueueAt);
}
}Workaround:
Implement and use a new interface and implementation that inherit from "ITopicPublisher" and "TopicPublisher"
public interface ICustomTopicPublisher : ITopicPublisher
{
void ScheduleTopic<T>(string topic, T data, TimeSpan delay);
void ScheduleTopic<T>(string topic, T data, DateTimeOffset enqueueAt);
}
public class CustomTopicPublisher : TopicPublisher, ICustomTopicPublisher
{
public CustomTopicPublisher(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
public void ScheduleTopic<T>(string topic, T data, TimeSpan delay)
{
BackgroundJob.Schedule(() => DispatchTopic(topic, data), delay);
}
public void ScheduleTopic<T>(string topic, T data, DateTimeOffset enqueueAt)
{
BackgroundJob.Schedule(() => DispatchTopic(topic, data), enqueueAt);
}
}
public static class CustomTopicPublisherExtensions
{
public static void AddCustomTopicServices(this IServiceCollection services)
{
services.AddTopicServices();
services.AddScoped<ICustomTopicPublisher, CustomTopicPublisher>();
}
}jeroneenkelmediaenkelmedia
Metadata
Metadata
Assignees
Labels
No labels