Skip to content

Commit 019f99d

Browse files
committed
* Finish up XML doc for IConnection / AmqpConnection
* Re-order methods in `AmqpConnection`
1 parent 486025d commit 019f99d

File tree

7 files changed

+187
-129
lines changed

7 files changed

+187
-129
lines changed

RabbitMQ.AMQP.Client/IConnection.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ public interface IConnection : ILifeCycle
4141
/// <summary>
4242
/// Get the properties for this connection.
4343
/// </summary>
44+
/// <returns><see cref="IReadOnlyDictionary{TKey, TValue}"/> of connection properties.</returns>
4445
public IReadOnlyDictionary<string, object> Properties { get; }
4546

4647
/// <summary>
4748
/// Get the <see cref="IPublisher"/> instances associated with this connection.
4849
/// </summary>
50+
/// <returns><see cref="IEnumerable{T}"/> of <see cref="IPublisher"/> instances.</returns>
4951
public IEnumerable<IPublisher> Publishers { get; }
5052

5153
/// <summary>
5254
/// Get the <see cref="IConsumer"/> instances associated with this connection.
5355
/// </summary>
56+
/// <returns><see cref="IEnumerable{T}"/> of <see cref="IConsumer"/> instances.</returns>
5457
public IEnumerable<IConsumer> Consumers { get; }
5558

5659
/// <summary>
57-
/// Get or set the Connection ID
60+
/// Get or set the Connection ID. Used by <see cref="IEnvironment"/>
5861
/// </summary>
5962
public long Id { get; set; }
6063
}

RabbitMQ.AMQP.Client/Impl/AmqpConnection.cs

Lines changed: 76 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
namespace RabbitMQ.AMQP.Client.Impl
1717
{
1818
/// <summary>
19-
/// AmqpConnection is the concrete implementation of <see cref="IConnection"/>
20-
/// It is a wrapper around the Microsoft AMQP.Net Lite <see cref="Connection"/> class
19+
/// <see cref="AmqpConnection"/> is the concrete implementation of <see cref="IConnection"/>.
20+
/// It is a wrapper around the Microsoft AMQP.Net Lite <see cref="Amqp.Connection"/> class.
2121
/// </summary>
2222
public class AmqpConnection : AbstractLifeCycle, IConnection
2323
{
@@ -62,45 +62,21 @@ public class AmqpConnection : AbstractLifeCycle, IConnection
6262
// TODO this is coupled with publishers and consumers
6363
internal readonly AmqpSessionManagement _nativePubSubSessions;
6464

65-
public IRpcServerBuilder RpcServerBuilder()
66-
{
67-
return new AmqpRpcServerBuilder(this);
68-
}
69-
70-
public IRpcClientBuilder RpcClientBuilder()
71-
{
72-
return new AmqpRpcClientBuilder(this);
73-
}
74-
75-
/// <summary>
76-
/// Read-only collection of publishers.
77-
/// See <see cref="IPublisher"/>
78-
/// </summary>
79-
/// <returns> All the active Publishers </returns>
80-
public IEnumerable<IPublisher> Publishers
81-
=> _publishersDict.Values.ToArray();
82-
83-
/// <summary>
84-
/// Read-only collection of consumers.
85-
/// See <see cref="IConsumer"/>
86-
/// </summary>
87-
/// <returns> All the active Consumers </returns>
88-
public IEnumerable<IConsumer> Consumers
89-
=> _consumersDict.Values.ToArray();
90-
9165
/// <summary>
92-
/// Read-only dictionary of connection properties.
93-
/// </summary>
94-
/// <returns><see cref="IReadOnlyDictionary{TKey, TValue}"/> of connection properties</returns>
95-
public IReadOnlyDictionary<string, object> Properties => _connectionProperties;
96-
97-
public long Id { get; set; }
98-
99-
/// <summary>
100-
/// Creates a new instance of <see cref="AmqpConnection"/>
101-
/// Through the Connection is possible to create:
102-
/// - Management. See <see cref="AmqpManagement"/>
103-
/// - Publishers and Consumers: See <see cref="AmqpPublisherBuilder"/> and <see cref="AmqpConsumerBuilder"/>
66+
/// <para>
67+
/// Creates a new instance of <see cref="AmqpConnection"/>
68+
/// </para>
69+
/// <para>
70+
/// Through this <see cref="IConnection"/> instance it is possible to create:
71+
/// <list type="bullet">
72+
/// <item>
73+
/// <see cref="IManagement"/>: See <see cref="AmqpManagement"/>.
74+
/// </item>
75+
/// <item>
76+
/// <see cref="IPublisher"/> and <see cref="IConsumer"/>. See <see cref="AmqpPublisherBuilder"/> and <see cref="AmqpConsumerBuilder"/>.
77+
/// </item>
78+
/// </list>
79+
/// </para>
10480
/// </summary>
10581
/// <param name="connectionSettings"></param>
10682
/// <param name="metricsReporter"></param>
@@ -110,29 +86,84 @@ public IEnumerable<IConsumer> Consumers
11086
public static async Task<IConnection> CreateAsync(ConnectionSettings connectionSettings,
11187
IMetricsReporter? metricsReporter = default)
11288
{
113-
var connection = new AmqpConnection(connectionSettings, metricsReporter);
89+
AmqpConnection connection = new(connectionSettings, metricsReporter);
11490
await connection.OpenAsync()
11591
.ConfigureAwait(false);
11692
return connection;
11793
}
11894

95+
/// <summary>
96+
/// The <see cref="IManagement"/> instance for this connection.
97+
/// </summary>
98+
/// <returns><see cref="IManagement"/> instance for this connection.</returns>
11999
public IManagement Management()
120100
{
121101
return _management;
122102
}
123103

104+
/// <summary>
105+
/// Create an <see cref="IPublisherBuilder"/> instance for this connection.
106+
/// </summary>
107+
/// <returns><see cref="IPublisherBuilder"/> instance for this connection.</returns>
108+
public IPublisherBuilder PublisherBuilder()
109+
{
110+
ThrowIfClosed();
111+
var publisherBuilder = new AmqpPublisherBuilder(this, _metricsReporter);
112+
return publisherBuilder;
113+
}
114+
115+
/// <summary>
116+
/// Create an <see cref="IConsumerBuilder"/> instance for this connection.
117+
/// </summary>
118+
/// <returns><see cref="IConsumerBuilder"/> instance for this connection.</returns>
124119
public IConsumerBuilder ConsumerBuilder()
125120
{
126121
return new AmqpConsumerBuilder(this, _metricsReporter);
127122
}
128123

129-
public IPublisherBuilder PublisherBuilder()
124+
/// <summary>
125+
/// Create an <see cref="IRpcServerBuilder"/> instance for this connection.
126+
/// </summary>
127+
/// <returns><see cref="IRpcServerBuilder"/> instance for this connection.</returns>
128+
public IRpcServerBuilder RpcServerBuilder()
130129
{
131-
ThrowIfClosed();
132-
var publisherBuilder = new AmqpPublisherBuilder(this, _metricsReporter);
133-
return publisherBuilder;
130+
return new AmqpRpcServerBuilder(this);
131+
}
132+
133+
/// <summary>
134+
/// Create an <see cref="IRpcClientBuilder"/> instance for this connection.
135+
/// </summary>
136+
/// <returns><see cref="IRpcClientBuilder"/> instance for this connection.</returns>
137+
public IRpcClientBuilder RpcClientBuilder()
138+
{
139+
return new AmqpRpcClientBuilder(this);
134140
}
135141

142+
/// <summary>
143+
/// Get the properties for this connection.
144+
/// </summary>
145+
/// <returns><see cref="IReadOnlyDictionary{TKey, TValue}"/> of connection properties.</returns>
146+
public IReadOnlyDictionary<string, object> Properties => _connectionProperties;
147+
148+
/// <summary>
149+
/// Get the <see cref="IPublisher"/> instances associated with this connection.
150+
/// </summary>
151+
/// <returns><see cref="IEnumerable{T}"/> of <see cref="IPublisher"/> instances.</returns>
152+
public IEnumerable<IPublisher> Publishers
153+
=> _publishersDict.Values.ToArray();
154+
155+
/// <summary>
156+
/// Get the <see cref="IConsumer"/> instances associated with this connection.
157+
/// </summary>
158+
/// <returns><see cref="IEnumerable{T}"/> of <see cref="IConsumer"/> instances.</returns>
159+
public IEnumerable<IConsumer> Consumers
160+
=> _consumersDict.Values.ToArray();
161+
162+
/// <summary>
163+
/// Get or set the Connection ID. Used by <see cref="AmqpEnvironment"/>
164+
/// </summary>
165+
public long Id { get; set; }
166+
136167
// TODO cancellation token
137168
public override async Task OpenAsync()
138169
{
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// This source code is dual-licensed under the Apache License, version 2.0,
2+
// and the Mozilla Public License, version 2.0.
3+
// Copyright (c) 2017-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
4+
5+
using System.Collections.Generic;
6+
7+
namespace RabbitMQ.AMQP.Client.Impl
8+
{
9+
internal class BindingSpec
10+
{
11+
private readonly IBindingSpecification _bindingSpecification;
12+
13+
internal BindingSpec(IBindingSpecification bindingSpecification)
14+
{
15+
_bindingSpecification = bindingSpecification;
16+
}
17+
18+
internal string SourceExchangeName => _bindingSpecification.SourceExchangeName;
19+
20+
internal string DestinationExchangeName => _bindingSpecification.DestinationExchangeName;
21+
22+
internal string DestinationQueueName => _bindingSpecification.DestinationQueueName;
23+
24+
internal string BindingKey => _bindingSpecification.BindingKey;
25+
26+
internal Dictionary<string, object> BindingArguments => _bindingSpecification.BindingArguments;
27+
28+
internal string BindingPath => _bindingSpecification.BindingPath;
29+
}
30+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This source code is dual-licensed under the Apache License, version 2.0,
2+
// and the Mozilla Public License, version 2.0.
3+
// Copyright (c) 2017-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
4+
5+
using System.Collections.Generic;
6+
7+
namespace RabbitMQ.AMQP.Client.Impl
8+
{
9+
internal class ExchangeSpec
10+
{
11+
private readonly IExchangeSpecification _exchangeSpecification;
12+
13+
internal ExchangeSpec(IExchangeSpecification exchangeSpecification)
14+
{
15+
_exchangeSpecification = exchangeSpecification;
16+
}
17+
18+
internal string ExchangeName => _exchangeSpecification.ExchangeName;
19+
20+
internal string ExchangeType => _exchangeSpecification.ExchangeType;
21+
22+
internal bool IsAutoDelete => _exchangeSpecification.IsAutoDelete;
23+
24+
internal Dictionary<string, object> ExchangeArguments => _exchangeSpecification.ExchangeArguments;
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This source code is dual-licensed under the Apache License, version 2.0,
2+
// and the Mozilla Public License, version 2.0.
3+
// Copyright (c) 2017-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
4+
5+
using System.Collections.Generic;
6+
7+
namespace RabbitMQ.AMQP.Client.Impl
8+
{
9+
internal class QueueSpec
10+
{
11+
private readonly IQueueSpecification _queueSpecification;
12+
13+
internal QueueSpec(IQueueSpecification queueSpecification)
14+
{
15+
_queueSpecification = queueSpecification;
16+
}
17+
18+
internal string QueueName => _queueSpecification.QueueName;
19+
20+
internal bool IsExclusive => _queueSpecification.IsExclusive;
21+
22+
internal bool IsAutoDelete => _queueSpecification.IsAutoDelete;
23+
24+
internal Dictionary<object, object> QueueArguments => _queueSpecification.QueueArguments;
25+
}
26+
}

0 commit comments

Comments
 (0)