Skip to content

Commit

Permalink
Add first Exchange Command (#18)
Browse files Browse the repository at this point in the history
* First Exchange command to create and delete 
* Fix Plurals 
* Add semaphore to sync the close

Signed-off-by: Gabriele Santomaggio <[email protected]>

---------

Signed-off-by: Gabriele Santomaggio <[email protected]>
  • Loading branch information
Gsantomaggio authored Jul 9, 2024
1 parent edfd006 commit 15b7132
Show file tree
Hide file tree
Showing 34 changed files with 542 additions and 216 deletions.
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
all: format test

format:
dotnet format $(CURDIR)/rabbitmq-amqp-dotnet-client.sln

build:
dotnet build $(CURDIR)/Build.csproj

test: build
dotnet test -c Debug $(CURDIR)/Tests/Tests.csproj --no-build --logger:"console;verbosity=detailed" /p:AltCover=true

rabbitmq-server-start:
./.ci/ubuntu/gha-setup.sh start

rabbitmq-server-stop:
./.ci/ubuntu/gha-setup.sh stop


# TODO:
## publish the documentation on github pages
## you should execute this command only on the `main` branch
# publish-github-pages:
# ## Create the PDF
# docker run -it -v $(shell pwd)/docs/:/client_doc/ asciidoctor/docker-asciidoctor /bin/bash -c "cd /client_doc/asciidoc && asciidoctor-pdf index.adoc"
# ## Create the HTML
# docker run -it -v $(shell pwd)/docs/:/client_doc/ asciidoctor/docker-asciidoctor /bin/bash -c "cd /client_doc/asciidoc && asciidoctor index.adoc"
# ## copy the PDF and HTML to temp folder
# rm -rf docs/temp
# mkdir -p docs/temp
# cp docs/asciidoc/index.pdf docs/temp/dotnet-stream-client.pdf
# cp docs/asciidoc/index.html docs/temp/index.html
# ## check out the gh-pages branch
# git checkout gh-pages
# ## copy the PDF and HTML to the root folder
# mv docs/temp/dotnet-stream-client.pdf stable/dotnet-stream-client.pdf
# mv docs/temp/index.html stable/htmlsingle/index.html
# ## commit and push
# git add stable/dotnet-stream-client.pdf
# git add stable/htmlsingle/index.html
# git commit -m "Update the documentation"
# git push origin gh-pages
# ## go back to the main branch
# git checkout main
14 changes: 11 additions & 3 deletions RabbitMQ.AMQP.Client/ByteCapacity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@ public long ToBytes()

public bool Equals(ByteCapacity? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(null, other))
{
return false;
}

if (ReferenceEquals(this, other))
{
return true;
}

return _bytes == other._bytes;
}
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IAddressBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public interface IAddressBuilder<out T>
T Queue(string queue);

T Key(string key);
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IClosable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public interface IClosable // TODO: Create an abstract class with the event and
public delegate void LifeCycleCallBack(object sender, State previousState, State currentState, Error? failureCause);

event LifeCycleCallBack ChangeState;
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public interface IConnection
{
IManagement Management();
Task ConnectAsync();
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public interface IConnectionSettings
string Scheme();

string ConnectionName();
}
}
20 changes: 20 additions & 0 deletions RabbitMQ.AMQP.Client/IEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,23 @@ 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);
}


public interface IExchangeDeletion
{
// TODO consider returning a ExchangeStatus object with some info after deletion
Task<IEntityInfo> Delete(string name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,17 @@ public interface IQueueInfo : IEntityInfo
ulong MessageCount();

uint ConsumerCount();
}
}


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

public interface IExchangeInfo : IEntityInfo
{
}
6 changes: 6 additions & 0 deletions RabbitMQ.AMQP.Client/IManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public interface IManagement : IClosable

IQueueDeletion QueueDeletion();

IExchangeSpecification Exchange();

IExchangeSpecification Exchange(string name);

IExchangeDeletion ExchangeDeletion();

ITopologyListener TopologyListener();
}

2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public interface IMessage
string Subject();
IMessage Subject(string subject);

}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public interface IPublisher : IClosable
{
Task Publish(IMessage message,
OutcomeDescriptorCallback outcomeCallback); // TODO: Add CancellationToken and callBack
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IPublisherBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public interface IPublisherBuilder : IAddressBuilder<IPublisherBuilder>

IPublisherBuilder MaxInflightMessages(int maxInFlight);
IPublisher Build();
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/IRecoveryConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ public interface IBackOffDelayPolicy
/// or when the user wants to disable the backoff delay policy.
/// </summary>
bool IsActive();
}
}
2 changes: 1 addition & 1 deletion RabbitMQ.AMQP.Client/ITopologyListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public interface ITopologyListener
void Clear();

int QueueCount();
}
}
8 changes: 6 additions & 2 deletions RabbitMQ.AMQP.Client/Impl/AbstractClosable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ protected void ThrowIfClosed()

protected void OnNewStatus(State newState, Error? error)
{
if (State == newState) return;
if (State == newState)
{
return;
}

var oldStatus = State;
State = newState;
ChangeState?.Invoke(this, oldStatus, newState, error);
}

public event IClosable.LifeCycleCallBack? ChangeState;
}
}
Loading

0 comments on commit 15b7132

Please sign in to comment.