Skip to content

Commit 87193c4

Browse files
authored
Merge pull request #758 from rabbitmq/rabbitmq-dotnet-client-515
Extract recovery events into a dedicated interface
2 parents ac13954 + bc91cd4 commit 87193c4

File tree

5 files changed

+66
-12
lines changed

5 files changed

+66
-12
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// This source code is dual-licensed under the Apache License, version
2+
// 2.0, and the Mozilla Public License, version 1.1.
3+
//
4+
// The APL v2.0:
5+
//
6+
//---------------------------------------------------------------------------
7+
// Copyright (c) 2007-2020 VMware, Inc.
8+
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// https://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
//---------------------------------------------------------------------------
21+
//
22+
// The MPL v1.1:
23+
//
24+
//---------------------------------------------------------------------------
25+
// The contents of this file are subject to the Mozilla Public License
26+
// Version 1.1 (the "License"); you may not use this file except in
27+
// compliance with the License. You may obtain a copy of the License
28+
// at https://www.mozilla.org/MPL/
29+
//
30+
// Software distributed under the License is distributed on an "AS IS"
31+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
32+
// the License for the specific language governing rights and
33+
// limitations under the License.
34+
//
35+
// The Original Code is RabbitMQ.
36+
//
37+
// The Initial Developer of the Original Code is Pivotal Software, Inc.
38+
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
39+
//---------------------------------------------------------------------------
40+
41+
using System;
42+
using System.Collections.Generic;
43+
using System.IO;
44+
using System.Threading;
45+
46+
using RabbitMQ.Client.Events;
47+
using RabbitMQ.Client.Exceptions;
48+
49+
namespace RabbitMQ.Client
50+
{
51+
/// <summary>
52+
/// Interface to an auto-recovering AMQP connection.
53+
/// </summary>
54+
public interface IAutorecoveringConnection : IConnection
55+
{
56+
event EventHandler<EventArgs> RecoverySucceeded;
57+
event EventHandler<ConnectionRecoveryErrorEventArgs> ConnectionRecoveryError;
58+
}
59+
}

projects/client/RabbitMQ.Client/src/client/api/IConnection.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ public interface IConnection : NetworkConnection, IDisposable
161161
/// of those event handlers throws an exception, as well.
162162
/// </remarks>
163163
event EventHandler<CallbackExceptionEventArgs> CallbackException;
164-
event EventHandler<EventArgs> RecoverySucceeded;
165-
event EventHandler<ConnectionRecoveryErrorEventArgs> ConnectionRecoveryError;
166-
167164

168165
event EventHandler<ConnectionBlockedEventArgs> ConnectionBlocked;
169166

projects/client/RabbitMQ.Client/src/client/impl/AutorecoveringConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
namespace RabbitMQ.Client.Framing.Impl
5252
{
53-
internal sealed class AutorecoveringConnection : IConnection
53+
internal sealed class AutorecoveringConnection : IAutorecoveringConnection
5454
{
5555
private readonly object _eventLock = new object();
5656

projects/client/RabbitMQ.Client/src/client/impl/Connection.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
namespace RabbitMQ.Client.Framing.Impl
5757
{
58-
class Connection : IConnection
58+
internal sealed class Connection : IConnection
5959
{
6060
private readonly object _eventLock = new object();
6161

@@ -128,11 +128,6 @@ public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHa
128128

129129
public Guid Id { get { return _id; } }
130130

131-
#pragma warning disable 67
132-
public event EventHandler<EventArgs> RecoverySucceeded;
133-
public event EventHandler<ConnectionRecoveryErrorEventArgs> ConnectionRecoveryError;
134-
#pragma warning restore 67
135-
136131
public event EventHandler<CallbackExceptionEventArgs> CallbackException;
137132

138133
public event EventHandler<ConnectionBlockedEventArgs> ConnectionBlocked;

projects/client/Unit/src/unit/APIApproval.Approve.approved.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ namespace RabbitMQ.Client
216216
{
217217
bool DispatchConsumersAsync { get; set; }
218218
}
219+
public interface IAutorecoveringConnection : RabbitMQ.Client.IConnection, RabbitMQ.Client.NetworkConnection, System.IDisposable
220+
{
221+
event System.EventHandler<RabbitMQ.Client.Events.ConnectionRecoveryErrorEventArgs> ConnectionRecoveryError;
222+
event System.EventHandler<System.EventArgs> RecoverySucceeded;
223+
}
219224
public interface IBasicConsumer
220225
{
221226
RabbitMQ.Client.IModel Model { get; }
@@ -295,10 +300,8 @@ namespace RabbitMQ.Client
295300
System.Collections.Generic.IList<RabbitMQ.Client.ShutdownReportEntry> ShutdownReport { get; }
296301
event System.EventHandler<RabbitMQ.Client.Events.CallbackExceptionEventArgs> CallbackException;
297302
event System.EventHandler<RabbitMQ.Client.Events.ConnectionBlockedEventArgs> ConnectionBlocked;
298-
event System.EventHandler<RabbitMQ.Client.Events.ConnectionRecoveryErrorEventArgs> ConnectionRecoveryError;
299303
event System.EventHandler<RabbitMQ.Client.ShutdownEventArgs> ConnectionShutdown;
300304
event System.EventHandler<System.EventArgs> ConnectionUnblocked;
301-
event System.EventHandler<System.EventArgs> RecoverySucceeded;
302305
void Abort();
303306
void Abort(System.TimeSpan timeout);
304307
void Abort(ushort reasonCode, string reasonText);

0 commit comments

Comments
 (0)