Skip to content

Commit 89faa33

Browse files
authored
Merge pull request #122 from mikehadlow/master
Added GetChannelsAsync overload that takes the connection.
2 parents e11161b + 570f8ac commit 89faa33

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

Source/EasyNetQ.Management.Client.IntegrationTests/ManagementClientTests.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,23 @@ public async Task Should_get_channels()
141141
}
142142
}
143143

144-
[Fact]
144+
[Fact]
145+
public async Task Should_get_channels_per_connection()
146+
{
147+
var connections = await managementClient.GetConnectionsAsync().ConfigureAwait(false);
148+
foreach (var connection in connections)
149+
{
150+
Console.Out.WriteLine("connection.Name = {0}", connection.Name);
151+
var channels = await managementClient.GetChannelsAsync(connection).ConfigureAwait(false);
152+
153+
foreach (var channel in channels)
154+
{
155+
Console.Out.WriteLine("\tchannel.Name = {0}", channel.Name);
156+
}
157+
}
158+
}
159+
160+
[Fact]
145161
public async Task Should_get_exchanges()
146162
{
147163
var exchanges = await managementClient.GetExchangesAsync().ConfigureAwait(false);

Source/EasyNetQ.Management.Client/IManagementClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ Task<Overview> GetOverviewAsync(
6565
/// <returns></returns>
6666
Task<IEnumerable<Channel>> GetChannelsAsync(CancellationToken cancellationToken = default(CancellationToken));
6767

68+
/// <summary>
69+
/// A list of all open channels for the given connection.
70+
/// </summary>
71+
/// <param name="connection"></param>
72+
/// <param name="cancellationToken"></param>
73+
/// <returns></returns>
74+
Task<IEnumerable<Channel>> GetChannelsAsync(Connection connection, CancellationToken cancellationToken = default(CancellationToken));
75+
6876
/// <summary>
6977
/// Gets the channel. This returns more detail, including consumers than the GetChannels method.
7078
/// </summary>

Source/EasyNetQ.Management.Client/ManagementClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ public Task<IEnumerable<Channel>> GetChannelsAsync(
173173
return GetAsync<IEnumerable<Channel>>("channels", cancellationToken);
174174
}
175175

176+
public Task<IEnumerable<Channel>> GetChannelsAsync(
177+
Connection connection,
178+
CancellationToken cancellationToken = default(CancellationToken))
179+
{
180+
return GetAsync<IEnumerable<Channel>>($"connections/{connection.Name}/channels", cancellationToken);
181+
}
182+
176183
public Task<Channel> GetChannelAsync(string channelName, GetRatesCriteria ratesCriteria = null,
177184
CancellationToken cancellationToken = default(CancellationToken))
178185
{

0 commit comments

Comments
 (0)