Skip to content

Implement purge command #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,44 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_allow_multiple_blank_lines_experimental = false:error
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
dotnet_code_quality_unused_parameters = non_public:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_diagnostic.RS0016.severity = error
dotnet_diagnostic.RS0017.severity = error
dotnet_diagnostic.RS0024.severity = error
dotnet_diagnostic.RS0025.severity = error
dotnet_diagnostic.RS0036.severity = warning

[*.cs]
# New line preferences
Expand Down Expand Up @@ -45,15 +83,15 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = warning
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_symbols.static_fields.applicable_accessibilities = internal, private, private_protected, protected
Expand All @@ -63,7 +101,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = internal, private, private_protected, protected
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
Expand Down Expand Up @@ -98,14 +136,14 @@ dotnet_style_prefer_conditional_expression_over_return = true:refactoring
csharp_prefer_simple_default_expression = true:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = true:refactoring
csharp_style_expression_bodied_constructors = true:refactoring
csharp_style_expression_bodied_operators = true:refactoring
csharp_style_expression_bodied_properties = true:refactoring
csharp_style_expression_bodied_indexers = true:refactoring
csharp_style_expression_bodied_accessors = true:refactoring
csharp_style_expression_bodied_lambdas = true:refactoring
csharp_style_expression_bodied_local_functions = true:refactoring
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_constructors = true:silent
csharp_style_expression_bodied_operators = true:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = true:silent

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
Expand Down Expand Up @@ -171,6 +209,28 @@ dotnet_diagnostic.RS0041.severity = none
dotnet_diagnostic.RS0051.severity = error

dotnet_diagnostic.CA2007.severity = error
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_prefer_static_anonymous_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_style_prefer_pattern_matching = true:silent
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion

# C++ Files
[*.{cpp,h,in}]
Expand Down
3 changes: 0 additions & 3 deletions RabbitMQ.AMQP.Client/ByteCapacity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ private ByteCapacity(long bytes) : this(bytes, bytes.ToString())
private const int GigabytesMultiplier = 1000 * 1000 * 1000;
private const long TerabytesMultiplier = 1000L * 1000L * 1000L * 1000L;


public static ByteCapacity B(long bytes)
{
return new ByteCapacity(bytes);
Expand All @@ -53,7 +52,6 @@ public static ByteCapacity Tb(long terabytes)
return new ByteCapacity(terabytes * TerabytesMultiplier);
}


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

public static ByteCapacity From(string value)
Expand Down Expand Up @@ -82,7 +80,6 @@ public long ToBytes()
return _bytes;
}


public bool Equals(ByteCapacity? other)
{
if (ReferenceEquals(null, other))
Expand Down
2 changes: 0 additions & 2 deletions RabbitMQ.AMQP.Client/IConsumerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public interface IConsumerBuilder

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


public interface IStreamOptions
{
IStreamOptions Offset(long offset);
Expand All @@ -50,7 +49,6 @@ public interface IStreamOptions
IConsumerBuilder Builder();
}


/// <summary>
/// ListenerContext is a helper class that holds the contexts for the listener
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions RabbitMQ.AMQP.Client/IEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public interface IQueueSpecification : IEntityInfoSpecification<IQueueInfo>
IQuorumQueueSpecification Quorum();

IClassicQueueSpecification Classic();

Task<ulong> PurgeAsync();
}

public interface IStreamSpecification
Expand Down
1 change: 0 additions & 1 deletion RabbitMQ.AMQP.Client/IEntitiesInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public interface IQueueInfo : IEntityInfo
uint ConsumerCount();
}


public enum ExchangeType
{
DIRECT,
Expand Down
7 changes: 7 additions & 0 deletions RabbitMQ.AMQP.Client/IManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public PreconditionFailedException(string message) : base(message)
}
}

public class BadRequestException : Exception
{
public BadRequestException(string message) : base(message)
{
}
}

/// <summary>
/// IManagement interface and is responsible for managing the AMQP resources.
/// RabbitMQ uses AMQP end point: "/management" to manage the resources like queues, exchanges, and bindings.
Expand Down
1 change: 0 additions & 1 deletion RabbitMQ.AMQP.Client/IMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public interface IMessage
string Subject();
IMessage Subject(string subject);


public IMessage Annotation(string key, object value);

public object Annotation(string key);
Expand Down
48 changes: 6 additions & 42 deletions RabbitMQ.AMQP.Client/Impl/AmqpBindingSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ public AmqpBindingSpecification(AmqpManagement management)
_topologyListener = ((IManagementTopology)_management).TopologyListener();
}

public string BindingPath
{
get
{
return BindingsTarget();
}
}
public string BindingPath => BindingsTarget();

public async Task BindAsync()
{
Expand Down Expand Up @@ -115,13 +109,7 @@ public IBindingSpecification SourceExchange(string exchangeName)
return this;
}

public string SourceExchangeName
{
get
{
return _sourceName;
}
}
public string SourceExchangeName => _sourceName;

public IBindingSpecification DestinationQueue(IQueueSpecification queueSpec)
{
Expand All @@ -135,13 +123,7 @@ public IBindingSpecification DestinationQueue(string queueName)
return this;
}

public string DestinationQueueName
{
get
{
return _destinationName;
}
}
public string DestinationQueueName => _destinationName;

public IBindingSpecification DestinationExchange(IExchangeSpecification exchangeSpec)
{
Expand All @@ -154,27 +136,15 @@ public IBindingSpecification DestinationExchange(string exchangeName)
return this;
}

public string DestinationExchangeName
{
get
{
return _destinationName;
}
}
public string DestinationExchangeName => _destinationName;

public IBindingSpecification Key(string bindingKey)
{
_routingKey = bindingKey;
return this;
}

public string BindingKey
{
get
{
return _routingKey;
}
}
public string BindingKey => _routingKey;

public IBindingSpecification Argument(string key, object value)
{
Expand All @@ -188,13 +158,7 @@ public IBindingSpecification Arguments(Dictionary<string, object> arguments)
return this;
}

public Dictionary<string, object> BindingArguments
{
get
{
return _arguments;
}
}
public Dictionary<string, object> BindingArguments => _arguments;

private string BindingsTarget()
{
Expand Down
11 changes: 1 addition & 10 deletions RabbitMQ.AMQP.Client/Impl/AmqpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class AmqpConnection : AbstractLifeCycle, IConnection
private readonly TaskCompletionSource<bool> _connectionClosedTcs =
new(TaskCreationOptions.RunContinuationsAsynchronously);


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


/// <summary>
/// Read-only collection of consumers.
/// See <see cref="IConsumer"/>
Expand Down Expand Up @@ -89,7 +87,6 @@ await connection.OpenAsync()
return connection;
}


public IManagement Management()
{
return _management;
Expand Down Expand Up @@ -165,13 +162,7 @@ public override string ToString()
return info;
}

internal Connection? NativeConnection
{
get
{
return _nativeConnection;
}
}
internal Connection? NativeConnection => _nativeConnection;

protected override void Dispose(bool disposing)
{
Expand Down
6 changes: 1 addition & 5 deletions RabbitMQ.AMQP.Client/Impl/AmqpConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public override async Task OpenAsync()
_configuration.ListenerContext?.Invoke(
new IConsumerBuilder.ListenerContext(new ListenerStreamOptions(_configuration.Filters)));


Attach attach = Utils.CreateAttach(_configuration.Address, DeliveryMode.AtLeastOnce, _id,
_configuration.Filters);

Expand Down Expand Up @@ -203,10 +202,7 @@ ref Unsafe.As<PauseStatus, int>(ref _pauseStatus),
}
}

public long UnsettledMessageCount
{
get { return _unsettledMessageCounter.Get(); }
}
public long UnsettledMessageCount => _unsettledMessageCounter.Get();

public void Unpause()
{
Expand Down
6 changes: 0 additions & 6 deletions RabbitMQ.AMQP.Client/Impl/AmqpConsumerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,18 @@ public IConsumerBuilder SubscriptionListener(Action<IConsumerBuilder.ListenerCon
return this;
}


public IConsumerBuilder.IStreamOptions Stream()
{
return new ConsumerBuilderStreamOptions(this, _configuration.Filters);
}


public async Task<IConsumer> BuildAndStartAsync(CancellationToken cancellationToken = default)
{
if (_configuration.Handler is null)
{
throw new ConsumerException("Message handler is not set");
}


AmqpConsumer consumer = new(_configuration);

// TODO pass cancellationToken
Expand All @@ -91,7 +88,6 @@ await consumer.OpenAsync()
}
}


/// <summary>
/// The base class for the stream options.
/// The class set the right filters used to create the consumer
Expand Down Expand Up @@ -144,7 +140,6 @@ public IConsumerBuilder.IStreamOptions FilterMatchUnfiltered(bool matchUnfiltere
public abstract IConsumerBuilder Builder();
}


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


public override IConsumerBuilder Builder()
{
return _consumerBuilder;
Expand Down
Loading