Skip to content

Commit 15b7132

Browse files
authored
Add first Exchange Command (#18)
* 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]>
1 parent edfd006 commit 15b7132

34 files changed

+542
-216
lines changed

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
all: format test
2+
3+
format:
4+
dotnet format $(CURDIR)/rabbitmq-amqp-dotnet-client.sln
5+
6+
build:
7+
dotnet build $(CURDIR)/Build.csproj
8+
9+
test: build
10+
dotnet test -c Debug $(CURDIR)/Tests/Tests.csproj --no-build --logger:"console;verbosity=detailed" /p:AltCover=true
11+
12+
rabbitmq-server-start:
13+
./.ci/ubuntu/gha-setup.sh start
14+
15+
rabbitmq-server-stop:
16+
./.ci/ubuntu/gha-setup.sh stop
17+
18+
19+
# TODO:
20+
## publish the documentation on github pages
21+
## you should execute this command only on the `main` branch
22+
# publish-github-pages:
23+
# ## Create the PDF
24+
# docker run -it -v $(shell pwd)/docs/:/client_doc/ asciidoctor/docker-asciidoctor /bin/bash -c "cd /client_doc/asciidoc && asciidoctor-pdf index.adoc"
25+
# ## Create the HTML
26+
# docker run -it -v $(shell pwd)/docs/:/client_doc/ asciidoctor/docker-asciidoctor /bin/bash -c "cd /client_doc/asciidoc && asciidoctor index.adoc"
27+
# ## copy the PDF and HTML to temp folder
28+
# rm -rf docs/temp
29+
# mkdir -p docs/temp
30+
# cp docs/asciidoc/index.pdf docs/temp/dotnet-stream-client.pdf
31+
# cp docs/asciidoc/index.html docs/temp/index.html
32+
# ## check out the gh-pages branch
33+
# git checkout gh-pages
34+
# ## copy the PDF and HTML to the root folder
35+
# mv docs/temp/dotnet-stream-client.pdf stable/dotnet-stream-client.pdf
36+
# mv docs/temp/index.html stable/htmlsingle/index.html
37+
# ## commit and push
38+
# git add stable/dotnet-stream-client.pdf
39+
# git add stable/htmlsingle/index.html
40+
# git commit -m "Update the documentation"
41+
# git push origin gh-pages
42+
# ## go back to the main branch
43+
# git checkout main

RabbitMQ.AMQP.Client/ByteCapacity.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,16 @@ public long ToBytes()
8080

8181
public bool Equals(ByteCapacity? other)
8282
{
83-
if (ReferenceEquals(null, other)) return false;
84-
if (ReferenceEquals(this, other)) return true;
83+
if (ReferenceEquals(null, other))
84+
{
85+
return false;
86+
}
87+
88+
if (ReferenceEquals(this, other))
89+
{
90+
return true;
91+
}
92+
8593
return _bytes == other._bytes;
8694
}
87-
}
95+
}

RabbitMQ.AMQP.Client/IAddressBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public interface IAddressBuilder<out T>
1010
T Queue(string queue);
1111

1212
T Key(string key);
13-
}
13+
}

RabbitMQ.AMQP.Client/IClosable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ public interface IClosable // TODO: Create an abstract class with the event and
2929
public delegate void LifeCycleCallBack(object sender, State previousState, State currentState, Error? failureCause);
3030

3131
event LifeCycleCallBack ChangeState;
32-
}
32+
}

RabbitMQ.AMQP.Client/IConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ public interface IConnection
66
{
77
IManagement Management();
88
Task ConnectAsync();
9-
}
9+
}

RabbitMQ.AMQP.Client/IConnectionSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public interface IConnectionSettings
1616
string Scheme();
1717

1818
string ConnectionName();
19-
}
19+
}

RabbitMQ.AMQP.Client/IEntities.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,23 @@ public interface IQueueDeletion
4343
// TODO consider returning a QueueStatus object with some info after deletion
4444
Task<IEntityInfo> Delete(string name);
4545
}
46+
47+
public interface IExchangeSpecification : IEntityDeclaration<IExchangeInfo>
48+
{
49+
IExchangeSpecification Name(string name);
50+
51+
IExchangeSpecification AutoDelete(bool autoDelete);
52+
53+
IExchangeSpecification Type(ExchangeType type);
54+
55+
IExchangeSpecification Type(string type);
56+
57+
IExchangeSpecification Argument(string key, object value);
58+
}
59+
60+
61+
public interface IExchangeDeletion
62+
{
63+
// TODO consider returning a ExchangeStatus object with some info after deletion
64+
Task<IEntityInfo> Delete(string name);
65+
}

RabbitMQ.AMQP.Client/IQueueInfo.cs renamed to RabbitMQ.AMQP.Client/IEntitiesInfo.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,17 @@ public interface IQueueInfo : IEntityInfo
2828
ulong MessageCount();
2929

3030
uint ConsumerCount();
31-
}
31+
}
32+
33+
34+
public enum ExchangeType
35+
{
36+
DIRECT,
37+
FANOUT,
38+
TOPIC,
39+
HEADERS
40+
}
41+
42+
public interface IExchangeInfo : IEntityInfo
43+
{
44+
}

RabbitMQ.AMQP.Client/IManagement.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ public interface IManagement : IClosable
1111

1212
IQueueDeletion QueueDeletion();
1313

14+
IExchangeSpecification Exchange();
15+
16+
IExchangeSpecification Exchange(string name);
17+
18+
IExchangeDeletion ExchangeDeletion();
19+
1420
ITopologyListener TopologyListener();
1521
}
1622

RabbitMQ.AMQP.Client/IMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public interface IMessage
1616
string Subject();
1717
IMessage Subject(string subject);
1818

19-
}
19+
}

0 commit comments

Comments
 (0)