Skip to content

Commit

Permalink
Fix plurars
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Santomaggio <[email protected]>
  • Loading branch information
Gsantomaggio committed Jul 8, 2024
1 parent 66db630 commit bf8f424
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 6 deletions.
13 changes: 13 additions & 0 deletions RabbitMQ.AMQP.Client/IEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ public interface IQueueDeletion
// TODO consider returning a QueueStatus object with some info after deletion
Task<IEntityInfo> Delete(string name);
}

public interface IExchangeSpecification : IEntityDeclaration<IExchangeInfo>
{
IExchangeSpecification Name(string name);

IExchangeSpecification AutoDelete(bool autoDelete);

IExchangeSpecification Type(ExchangeType type);

IExchangeSpecification Type(string type);

IExchangeSpecification Argument(string key, object value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ public interface IQueueInfo : IEntityInfo

uint ConsumerCount();
}


public enum ExchangeType {
DIRECT,
FANOUT,
TOPIC,
HEADERS
}

public interface IExchangeInfo : IEntityInfo
{
}
39 changes: 39 additions & 0 deletions RabbitMQ.AMQP.Client/Impl/AmqpExchangeSpecification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace RabbitMQ.AMQP.Client.Impl;

public class AmqpExchangeSpecification : IExchangeSpecification
{

private string _name = "";
private bool _autoDelete;
private ExchangeType _type;
private string _typeString = "";


public Task<IExchangeInfo> Declare() => throw new NotImplementedException();

public IExchangeSpecification Name(string name)
{
_name = name;
return this;
}

public IExchangeSpecification AutoDelete(bool autoDelete)
{
_autoDelete = autoDelete;
return this;
}

public IExchangeSpecification Type(ExchangeType type)
{
_type = type;
return this;
}

public IExchangeSpecification Type(string type)
{
_typeString = type;
return this;
}

public IExchangeSpecification Argument(string key, object value) => throw new NotImplementedException();
}
6 changes: 3 additions & 3 deletions RabbitMQ.AMQP.Client/Impl/AmqpPublisherBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public string Address()

if (!string.IsNullOrEmpty(_key))
{
return "/exchange/" + _exchange + "/key/" + _key;
return "/exchanges/" + _exchange + "/key/" + _key;
}

return "/exchange/" + _exchange;
return "/exchanges/" + _exchange;
}

if (_queue == null)
Expand All @@ -63,7 +63,7 @@ public string Address()
throw new InvalidAddressException("Queue must be set");
}

return "/queue/" + _queue;
return "/queues/" + _queue;
}
}

Expand Down
6 changes: 3 additions & 3 deletions RabbitMQ.AMQP.Client/Impl/AmqpQueueSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal DefaultQueueInfo(Map response)
: m.ToDictionary(kv => (string)kv.Key, kv => kv.Value);

_leader = (string)response["leader"];
var replicas = (string[])response["replicas"];
string[]? replicas = (string[])response["replicas"];
_replicas = replicas.Length == 0 ? [] : [.. replicas];
_messageCount = (ulong)response["message_count"];
_consumerCount = (uint)response["consumer_count"];
Expand Down Expand Up @@ -139,7 +139,7 @@ public IQueueSpecification AutoDelete(bool autoDelete)

public IQueueSpecification Arguments(Dictionary<object, object> arguments)
{
foreach (var (key, value) in arguments)
foreach ((object key, object value) in arguments)
{
_arguments[key] = value;
}
Expand All @@ -150,7 +150,7 @@ public IQueueSpecification Arguments(Dictionary<object, object> arguments)
public Dictionary<object, object> Arguments()
{
var result = new Dictionary<object, object>();
foreach (var (key, value) in _arguments)
foreach ((object? key, object? value) in _arguments)
{
result[key] = value;
}
Expand Down

0 comments on commit bf8f424

Please sign in to comment.