55using Microsoft . Extensions . Logging ;
66using StackExchange . Redis ;
77using WorkflowCore . Interface ;
8+ using WorkflowCore . Models ;
89
910namespace WorkflowCore . Providers . Redis . Services
1011{
@@ -24,15 +25,25 @@ public class RedisQueueProvider : IQueueProvider
2425 [ QueueType . Index ] = "index"
2526 } ;
2627
27- public RedisQueueProvider ( string connectionString , string prefix , ILoggerFactory logFactory )
28+ private readonly Dictionary < QueueType , bool > _enabledQueues = new Dictionary < QueueType , bool > ( ) ;
29+
30+ public RedisQueueProvider ( string connectionString , string prefix , WorkflowOptions options , ILoggerFactory logFactory )
2831 {
2932 _connectionString = connectionString ;
3033 _prefix = prefix ;
34+ _enabledQueues [ QueueType . Index ] = options . EnableIndexes ;
35+ _enabledQueues [ QueueType . Event ] = options . EnableEvents ;
36+ _enabledQueues [ QueueType . Workflow ] = options . EnableWorkflows ;
3137 _logger = logFactory . CreateLogger ( GetType ( ) ) ;
3238 }
3339
3440 public async Task QueueWork ( string id , QueueType queue )
3541 {
42+ if ( ! _enabledQueues [ queue ] )
43+ {
44+ return ;
45+ }
46+
3647 if ( _redis == null )
3748 throw new InvalidOperationException ( ) ;
3849
@@ -47,6 +58,11 @@ public async Task QueueWork(string id, QueueType queue)
4758
4859 public async Task < string > DequeueWork ( QueueType queue , CancellationToken cancellationToken )
4960 {
61+ if ( ! _enabledQueues [ queue ] )
62+ {
63+ return null ;
64+ }
65+
5066 if ( _redis == null )
5167 throw new InvalidOperationException ( ) ;
5268
0 commit comments