File tree Expand file tree Collapse file tree 3 files changed +35
-30
lines changed Expand file tree Collapse file tree 3 files changed +35
-30
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ using CommandLine ;
2+ using InEngine . Core . Exceptions ;
3+
4+ namespace InEngine . Core . Queue . Commands
5+ {
6+ public class Flush : AbstractCommand
7+ {
8+ [ Option ( "pending" , HelpText = "Clear the pending queue." ) ]
9+ public bool ClearPendingQueue { get ; set ; }
10+
11+ [ Option ( "failed" , HelpText = "Clear the failed queue." ) ]
12+ public bool ClearFailedQueue { get ; set ; }
13+
14+ [ Option ( "in-progress" , HelpText = "Clear the in-progress queue." ) ]
15+ public bool ClearInProgressQueue { get ; set ; }
16+
17+ [ Option ( "secondary" , HelpText = "Clear secondary queues. Primary queues are cleared by default." ) ]
18+ public bool UseSecondaryQueue { get ; set ; }
19+
20+ public override void Run ( )
21+ {
22+ if ( ClearPendingQueue == false && ClearFailedQueue == false && ClearInProgressQueue == false )
23+ throw new CommandFailedException ( "Must specify at least one queue to clear. Use -h to see available options." ) ;
24+ var broker = Broker . Make ( UseSecondaryQueue ) ;
25+ if ( ClearPendingQueue )
26+ Info ( $ "Pending: { broker . ClearPendingQueue ( ) . ToString ( ) } ") ;
27+ if ( ClearInProgressQueue )
28+ Info ( $ "In-progress: { broker . ClearInProgressQueue ( ) . ToString ( ) } ") ;
29+ if ( ClearFailedQueue )
30+ Info ( $ "Failed: { broker . ClearFailedQueue ( ) . ToString ( ) } ") ;
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ public class Options : IOptions
1515 [ VerbOption ( "queue:length" , HelpText = "Get the number of messages in the primary and secondary queues." ) ]
1616 public Length Length { get ; set ; }
1717
18- [ VerbOption ( "queue:clear " , HelpText = "Clear the primary or secondary queues, and optionally." ) ]
19- public ClearAll ClearAll { get ; set ; }
18+ [ VerbOption ( "queue:flush " , HelpText = "Clear the primary or secondary queues, and optionally." ) ]
19+ public Flush Flush { get ; set ; }
2020
2121 [ VerbOption ( "queue:republish" , HelpText = "Republish failed messages to the queue." ) ]
2222 public RepublishFailed RepublishFailed { get ; set ; }
You can’t perform that action at this time.
0 commit comments