Skip to content

Commit 042a55a

Browse files
authored
Merge pull request #73 from rabbitmq/purge
Implement purge command
2 parents 65b44e6 + 2fba89f commit 042a55a

35 files changed

+199
-306
lines changed

.editorconfig

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,44 @@ trim_trailing_whitespace = true
66
insert_final_newline = true
77
indent_style = space
88
indent_size = 4
9+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
10+
tab_width = 4
11+
dotnet_style_coalesce_expression = true:suggestion
12+
dotnet_style_null_propagation = true:suggestion
13+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
14+
dotnet_style_prefer_auto_properties = true:suggestion
15+
dotnet_style_object_initializer = true:suggestion
16+
dotnet_style_collection_initializer = true:suggestion
17+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
18+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
19+
dotnet_style_prefer_conditional_expression_over_return = true:silent
20+
dotnet_style_explicit_tuple_names = true:suggestion
21+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
22+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
23+
dotnet_style_prefer_compound_assignment = true:suggestion
24+
dotnet_style_prefer_simplified_interpolation = true:suggestion
25+
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
26+
dotnet_style_namespace_match_folder = true:suggestion
27+
dotnet_style_readonly_field = true:suggestion
28+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
29+
dotnet_style_predefined_type_for_member_access = true:suggestion
30+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
31+
dotnet_style_allow_multiple_blank_lines_experimental = false:error
32+
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
33+
dotnet_code_quality_unused_parameters = non_public:suggestion
34+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
35+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
36+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
37+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
38+
dotnet_style_qualification_for_field = false:suggestion
39+
dotnet_style_qualification_for_property = false:suggestion
40+
dotnet_style_qualification_for_method = false:suggestion
41+
dotnet_style_qualification_for_event = false:suggestion
42+
dotnet_diagnostic.RS0016.severity = error
43+
dotnet_diagnostic.RS0017.severity = error
44+
dotnet_diagnostic.RS0024.severity = error
45+
dotnet_diagnostic.RS0025.severity = error
46+
dotnet_diagnostic.RS0036.severity = warning
947

1048
[*.cs]
1149
# New line preferences
@@ -45,15 +83,15 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
4583
# name all constant fields using PascalCase
4684
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
4785
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
48-
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
86+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
4987
dotnet_naming_symbols.constant_fields.applicable_kinds = field
5088
dotnet_naming_symbols.constant_fields.required_modifiers = const
5189
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
5290

5391
# static fields should have s_ prefix
5492
dotnet_naming_rule.static_fields_should_have_prefix.severity = warning
5593
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
56-
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
94+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
5795
dotnet_naming_symbols.static_fields.applicable_kinds = field
5896
dotnet_naming_symbols.static_fields.required_modifiers = static
5997
dotnet_naming_symbols.static_fields.applicable_accessibilities = internal, private, private_protected, protected
@@ -63,7 +101,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
63101
# internal and private fields should be _camelCase
64102
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
65103
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
66-
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
104+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
67105
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
68106
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = internal, private, private_protected, protected
69107
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
@@ -98,14 +136,14 @@ dotnet_style_prefer_conditional_expression_over_return = true:refactoring
98136
csharp_prefer_simple_default_expression = true:suggestion
99137

100138
# Expression-bodied members
101-
csharp_style_expression_bodied_methods = true:refactoring
102-
csharp_style_expression_bodied_constructors = true:refactoring
103-
csharp_style_expression_bodied_operators = true:refactoring
104-
csharp_style_expression_bodied_properties = true:refactoring
105-
csharp_style_expression_bodied_indexers = true:refactoring
106-
csharp_style_expression_bodied_accessors = true:refactoring
107-
csharp_style_expression_bodied_lambdas = true:refactoring
108-
csharp_style_expression_bodied_local_functions = true:refactoring
139+
csharp_style_expression_bodied_methods = true:silent
140+
csharp_style_expression_bodied_constructors = true:silent
141+
csharp_style_expression_bodied_operators = true:silent
142+
csharp_style_expression_bodied_properties = true:silent
143+
csharp_style_expression_bodied_indexers = true:silent
144+
csharp_style_expression_bodied_accessors = true:silent
145+
csharp_style_expression_bodied_lambdas = true:silent
146+
csharp_style_expression_bodied_local_functions = true:silent
109147

110148
# Pattern matching
111149
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
@@ -171,6 +209,28 @@ dotnet_diagnostic.RS0041.severity = none
171209
dotnet_diagnostic.RS0051.severity = error
172210

173211
dotnet_diagnostic.CA2007.severity = error
212+
csharp_style_namespace_declarations = block_scoped:silent
213+
csharp_style_prefer_method_group_conversion = true:silent
214+
csharp_style_prefer_top_level_statements = true:silent
215+
csharp_style_prefer_primary_constructors = true:suggestion
216+
csharp_style_prefer_null_check_over_type_check = true:suggestion
217+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
218+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
219+
csharp_style_prefer_tuple_swap = true:suggestion
220+
csharp_style_prefer_utf8_string_literals = true:suggestion
221+
csharp_style_deconstructed_variable_declaration = true:suggestion
222+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
223+
csharp_prefer_static_anonymous_function = true:suggestion
224+
csharp_style_prefer_readonly_struct = true:suggestion
225+
csharp_style_prefer_readonly_struct_member = true:suggestion
226+
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
227+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
228+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
229+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
230+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
231+
csharp_style_prefer_pattern_matching = true:silent
232+
csharp_style_prefer_not_pattern = true:suggestion
233+
csharp_style_prefer_extended_property_pattern = true:suggestion
174234

175235
# C++ Files
176236
[*.{cpp,h,in}]

RabbitMQ.AMQP.Client/ByteCapacity.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ private ByteCapacity(long bytes) : this(bytes, bytes.ToString())
2727
private const int GigabytesMultiplier = 1000 * 1000 * 1000;
2828
private const long TerabytesMultiplier = 1000L * 1000L * 1000L * 1000L;
2929

30-
3130
public static ByteCapacity B(long bytes)
3231
{
3332
return new ByteCapacity(bytes);
@@ -53,7 +52,6 @@ public static ByteCapacity Tb(long terabytes)
5352
return new ByteCapacity(terabytes * TerabytesMultiplier);
5453
}
5554

56-
5755
private static readonly Regex s_sizeRegex = new Regex(@"^(\d+)([kKmMgGtTpP]?[bB]?)$", RegexOptions.Compiled);
5856

5957
public static ByteCapacity From(string value)
@@ -82,7 +80,6 @@ public long ToBytes()
8280
return _bytes;
8381
}
8482

85-
8683
public bool Equals(ByteCapacity? other)
8784
{
8885
if (ReferenceEquals(null, other))

RabbitMQ.AMQP.Client/IConsumerBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public interface IConsumerBuilder
4040

4141
Task<IConsumer> BuildAndStartAsync(CancellationToken cancellationToken = default);
4242

43-
4443
public interface IStreamOptions
4544
{
4645
IStreamOptions Offset(long offset);
@@ -50,7 +49,6 @@ public interface IStreamOptions
5049
IConsumerBuilder Builder();
5150
}
5251

53-
5452
/// <summary>
5553
/// ListenerContext is a helper class that holds the contexts for the listener
5654
/// </summary>

RabbitMQ.AMQP.Client/IEntities.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public interface IQueueSpecification : IEntityInfoSpecification<IQueueInfo>
8181
IQuorumQueueSpecification Quorum();
8282

8383
IClassicQueueSpecification Classic();
84+
85+
Task<ulong> PurgeAsync();
8486
}
8587

8688
public interface IStreamSpecification

RabbitMQ.AMQP.Client/IEntitiesInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public interface IQueueInfo : IEntityInfo
3939
uint ConsumerCount();
4040
}
4141

42-
4342
public enum ExchangeType
4443
{
4544
DIRECT,

RabbitMQ.AMQP.Client/IManagement.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public PreconditionFailedException(string message) : base(message)
2222
}
2323
}
2424

25+
public class BadRequestException : Exception
26+
{
27+
public BadRequestException(string message) : base(message)
28+
{
29+
}
30+
}
31+
2532
/// <summary>
2633
/// IManagement interface and is responsible for managing the AMQP resources.
2734
/// RabbitMQ uses AMQP end point: "/management" to manage the resources like queues, exchanges, and bindings.

RabbitMQ.AMQP.Client/IMessage.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public interface IMessage
2424
string Subject();
2525
IMessage Subject(string subject);
2626

27-
2827
public IMessage Annotation(string key, object value);
2928

3029
public object Annotation(string key);

RabbitMQ.AMQP.Client/Impl/AmqpBindingSpecification.cs

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ public AmqpBindingSpecification(AmqpManagement management)
4141
_topologyListener = ((IManagementTopology)_management).TopologyListener();
4242
}
4343

44-
public string BindingPath
45-
{
46-
get
47-
{
48-
return BindingsTarget();
49-
}
50-
}
44+
public string BindingPath => BindingsTarget();
5145

5246
public async Task BindAsync()
5347
{
@@ -115,13 +109,7 @@ public IBindingSpecification SourceExchange(string exchangeName)
115109
return this;
116110
}
117111

118-
public string SourceExchangeName
119-
{
120-
get
121-
{
122-
return _sourceName;
123-
}
124-
}
112+
public string SourceExchangeName => _sourceName;
125113

126114
public IBindingSpecification DestinationQueue(IQueueSpecification queueSpec)
127115
{
@@ -135,13 +123,7 @@ public IBindingSpecification DestinationQueue(string queueName)
135123
return this;
136124
}
137125

138-
public string DestinationQueueName
139-
{
140-
get
141-
{
142-
return _destinationName;
143-
}
144-
}
126+
public string DestinationQueueName => _destinationName;
145127

146128
public IBindingSpecification DestinationExchange(IExchangeSpecification exchangeSpec)
147129
{
@@ -154,27 +136,15 @@ public IBindingSpecification DestinationExchange(string exchangeName)
154136
return this;
155137
}
156138

157-
public string DestinationExchangeName
158-
{
159-
get
160-
{
161-
return _destinationName;
162-
}
163-
}
139+
public string DestinationExchangeName => _destinationName;
164140

165141
public IBindingSpecification Key(string bindingKey)
166142
{
167143
_routingKey = bindingKey;
168144
return this;
169145
}
170146

171-
public string BindingKey
172-
{
173-
get
174-
{
175-
return _routingKey;
176-
}
177-
}
147+
public string BindingKey => _routingKey;
178148

179149
public IBindingSpecification Argument(string key, object value)
180150
{
@@ -188,13 +158,7 @@ public IBindingSpecification Arguments(Dictionary<string, object> arguments)
188158
return this;
189159
}
190160

191-
public Dictionary<string, object> BindingArguments
192-
{
193-
get
194-
{
195-
return _arguments;
196-
}
197-
}
161+
public Dictionary<string, object> BindingArguments => _arguments;
198162

199163
private string BindingsTarget()
200164
{

RabbitMQ.AMQP.Client/Impl/AmqpConnection.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class AmqpConnection : AbstractLifeCycle, IConnection
5050
private readonly TaskCompletionSource<bool> _connectionClosedTcs =
5151
new(TaskCreationOptions.RunContinuationsAsynchronously);
5252

53-
5453
/// <summary>
5554
/// Read-only collection of publishers.
5655
/// See <see cref="IPublisher"/>
@@ -61,7 +60,6 @@ public ReadOnlyCollection<IPublisher> GetPublishers()
6160
return Publishers.Values.ToList().AsReadOnly();
6261
}
6362

64-
6563
/// <summary>
6664
/// Read-only collection of consumers.
6765
/// See <see cref="IConsumer"/>
@@ -89,7 +87,6 @@ await connection.OpenAsync()
8987
return connection;
9088
}
9189

92-
9390
public IManagement Management()
9491
{
9592
return _management;
@@ -165,13 +162,7 @@ public override string ToString()
165162
return info;
166163
}
167164

168-
internal Connection? NativeConnection
169-
{
170-
get
171-
{
172-
return _nativeConnection;
173-
}
174-
}
165+
internal Connection? NativeConnection => _nativeConnection;
175166

176167
protected override void Dispose(bool disposing)
177168
{

RabbitMQ.AMQP.Client/Impl/AmqpConsumer.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public override async Task OpenAsync()
5353
_configuration.ListenerContext?.Invoke(
5454
new IConsumerBuilder.ListenerContext(new ListenerStreamOptions(_configuration.Filters)));
5555

56-
5756
Attach attach = Utils.CreateAttach(_configuration.Address, DeliveryMode.AtLeastOnce, _id,
5857
_configuration.Filters);
5958

@@ -203,10 +202,7 @@ ref Unsafe.As<PauseStatus, int>(ref _pauseStatus),
203202
}
204203
}
205204

206-
public long UnsettledMessageCount
207-
{
208-
get { return _unsettledMessageCounter.Get(); }
209-
}
205+
public long UnsettledMessageCount => _unsettledMessageCounter.Get();
210206

211207
public void Unpause()
212208
{

RabbitMQ.AMQP.Client/Impl/AmqpConsumerBuilder.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,18 @@ public IConsumerBuilder SubscriptionListener(Action<IConsumerBuilder.ListenerCon
6666
return this;
6767
}
6868

69-
7069
public IConsumerBuilder.IStreamOptions Stream()
7170
{
7271
return new ConsumerBuilderStreamOptions(this, _configuration.Filters);
7372
}
7473

75-
7674
public async Task<IConsumer> BuildAndStartAsync(CancellationToken cancellationToken = default)
7775
{
7876
if (_configuration.Handler is null)
7977
{
8078
throw new ConsumerException("Message handler is not set");
8179
}
8280

83-
8481
AmqpConsumer consumer = new(_configuration);
8582

8683
// TODO pass cancellationToken
@@ -91,7 +88,6 @@ await consumer.OpenAsync()
9188
}
9289
}
9390

94-
9591
/// <summary>
9692
/// The base class for the stream options.
9793
/// The class set the right filters used to create the consumer
@@ -144,7 +140,6 @@ public IConsumerBuilder.IStreamOptions FilterMatchUnfiltered(bool matchUnfiltere
144140
public abstract IConsumerBuilder Builder();
145141
}
146142

147-
148143
/// <summary>
149144
/// The stream options for the Subscribe Listener event.
150145
/// For the user perspective, it is used to set the stream options for the listener
@@ -177,7 +172,6 @@ public ConsumerBuilderStreamOptions(IConsumerBuilder consumerBuilder, Map filter
177172
_consumerBuilder = consumerBuilder;
178173
}
179174

180-
181175
public override IConsumerBuilder Builder()
182176
{
183177
return _consumerBuilder;

0 commit comments

Comments
 (0)