Skip to content

Commit a0b3a03

Browse files
committed
Adjust event args and declaration
1 parent 17d2903 commit a0b3a03

23 files changed

+83
-53
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public interface IConnection : INetworkConnection, IDisposable
161161
/// <remarks>
162162
/// This event will never fire for connections that disable automatic recovery.
163163
/// </remarks>
164-
event AsyncEventHandler<EventArgs> RecoverySucceededAsync;
164+
event AsyncEventHandler<AsyncEventArgs> RecoverySucceededAsync;
165165

166166
/// <summary>
167167
/// Raised when the connection recovery fails, e.g. because reconnection or topology
@@ -212,7 +212,7 @@ public interface IConnection : INetworkConnection, IDisposable
212212
/// <summary>
213213
/// Raised when a connection is unblocked by the AMQP broker.
214214
/// </summary>
215-
event AsyncEventHandler<EventArgs> ConnectionUnblockedAsync;
215+
event AsyncEventHandler<AsyncEventArgs> ConnectionUnblockedAsync;
216216

217217
/// <summary>
218218
/// This method updates the secret used to authenticate this connection.

projects/RabbitMQ.Client/client/api/IRecoverable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ namespace RabbitMQ.Client
3939
/// </summary>
4040
public interface IRecoverable
4141
{
42-
event AsyncEventHandler<EventArgs> RecoveryAsync;
42+
event AsyncEventHandler<AsyncEventArgs> RecoveryAsync;
4343
}
4444
}

projects/RabbitMQ.Client/client/api/ShutdownEventArgs.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Threading;
34+
using RabbitMQ.Client.Events;
3335

3436
namespace RabbitMQ.Client
3537
{
@@ -39,7 +41,8 @@ namespace RabbitMQ.Client
3941
/// <remarks>
4042
/// The <see cref="ClassId"/> and <see cref="Initiator"/> properties should be used to determine the originator of the shutdown event.
4143
/// </remarks>
42-
public class ShutdownEventArgs : EventArgs
44+
/// TODO: Should this be moved to the events folder and the namespace be adjusted?
45+
public class ShutdownEventArgs : AsyncEventArgs
4346
{
4447
private readonly Exception? _exception;
4548

@@ -48,16 +51,17 @@ public class ShutdownEventArgs : EventArgs
4851
/// 0 for <see cref="ClassId"/> and <see cref="MethodId"/>.
4952
/// </summary>
5053
public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText,
51-
object? cause = null)
52-
: this(initiator, replyCode, replyText, 0, 0, cause)
54+
object? cause = null, CancellationToken cancellationToken = default)
55+
: this(initiator, replyCode, replyText, 0, 0, cause, cancellationToken: cancellationToken)
5356
{
5457
}
5558

5659
/// <summary>
5760
/// Construct a <see cref="ShutdownEventArgs"/> with the given parameters.
5861
/// </summary>
5962
public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText,
60-
ushort classId, ushort methodId, object? cause = null)
63+
ushort classId, ushort methodId, object? cause = null, CancellationToken cancellationToken = default)
64+
: base(cancellationToken)
6165
{
6266
Initiator = initiator;
6367
ReplyCode = replyCode;
@@ -70,8 +74,8 @@ public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string r
7074
/// <summary>
7175
/// Construct a <see cref="ShutdownEventArgs"/> with the given parameters.
7276
/// </summary>
73-
public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText, Exception exception)
74-
: this(initiator, replyCode, replyText, 0, 0)
77+
public ShutdownEventArgs(ShutdownInitiator initiator, ushort replyCode, string replyText, Exception exception, CancellationToken cancellationToken = default)
78+
: this(initiator, replyCode, replyText, 0, 0, cancellationToken: cancellationToken)
7579
{
7680
_exception = exception ?? throw new ArgumentNullException(nameof(exception));
7781
}

projects/RabbitMQ.Client/client/events/AsyncEventArgs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class AsyncEventArgs
5151
/// default value is <see cref="CancellationToken.None"/>.
5252
/// </param>
5353
public AsyncEventArgs(CancellationToken cancellationToken = default)
54+
: base()
5455
{
5556
CancellationToken = cancellationToken;
5657
}

projects/RabbitMQ.Client/client/events/BasicAckEventArgs.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Threading;
3334

3435
namespace RabbitMQ.Client.Events
3536
{
3637
///<summary>Contains all the information about a message acknowledged
3738
///from an AMQP broker within the Basic content-class.</summary>
38-
public class BasicAckEventArgs : EventArgs
39+
public class BasicAckEventArgs : AsyncEventArgs
3940
{
40-
public BasicAckEventArgs(ulong deliveryTag, bool multiple)
41-
: base()
41+
public BasicAckEventArgs(ulong deliveryTag, bool multiple, CancellationToken cancellationToken = default)
42+
: base(cancellationToken)
4243
{
4344
DeliveryTag = deliveryTag;
4445
Multiple = multiple;

projects/RabbitMQ.Client/client/events/BasicDeliverEventArgs.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Threading;
3334

3435
namespace RabbitMQ.Client.Events
3536
{
3637
///<summary>Contains all the information about a message delivered
3738
///from an AMQP broker within the Basic content-class.</summary>
38-
public class BasicDeliverEventArgs : EventArgs
39+
public class BasicDeliverEventArgs : AsyncEventArgs
3940
{
4041
///<summary>Constructor that fills the event's properties from
4142
///its arguments.</summary>
@@ -45,7 +46,8 @@ public BasicDeliverEventArgs(string consumerTag,
4546
string exchange,
4647
string routingKey,
4748
IReadOnlyBasicProperties properties,
48-
ReadOnlyMemory<byte> body) : base()
49+
ReadOnlyMemory<byte> body,
50+
CancellationToken cancellationToken = default) : base(cancellationToken)
4951
{
5052
ConsumerTag = consumerTag;
5153
DeliveryTag = deliveryTag;

projects/RabbitMQ.Client/client/events/BasicNackEventArgs.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Threading;
3334

3435
namespace RabbitMQ.Client.Events
3536
{
3637
///<summary>Contains all the information about a message nack'd
3738
///from an AMQP broker within the Basic content-class.</summary>
38-
public class BasicNackEventArgs : EventArgs
39+
public class BasicNackEventArgs : AsyncEventArgs
3940
{
40-
public BasicNackEventArgs(ulong deliveryTag, bool multiple, bool requeue)
41-
: base()
41+
public BasicNackEventArgs(ulong deliveryTag, bool multiple, bool requeue, CancellationToken cancellationToken = default)
42+
: base(cancellationToken)
4243
{
4344
DeliveryTag = deliveryTag;
4445
Multiple = multiple;

projects/RabbitMQ.Client/client/events/BasicReturnEventArgs.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Threading;
3334

3435
namespace RabbitMQ.Client.Events
3536
{
3637
///<summary>Contains all the information about a message returned
3738
///from an AMQP broker within the Basic content-class.</summary>
38-
public class BasicReturnEventArgs : EventArgs
39+
public class BasicReturnEventArgs : AsyncEventArgs
3940
{
4041
public BasicReturnEventArgs(
4142
ushort replyCode,
4243
string replyText,
4344
string exchange,
4445
string routingKey,
4546
IReadOnlyBasicProperties basicProperties,
46-
ReadOnlyMemory<byte> body) : base()
47+
ReadOnlyMemory<byte> body,
48+
CancellationToken cancellationToken = default) : base(cancellationToken)
4749
{
4850
ReplyCode = replyCode;
4951
ReplyText = replyText;

projects/RabbitMQ.Client/client/events/CallbackExceptionEventArgs.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131

3232
using System;
3333
using System.Collections.Generic;
34+
using System.Threading;
3435

3536
namespace RabbitMQ.Client.Events
3637
{
37-
public abstract class BaseExceptionEventArgs : EventArgs
38+
public abstract class BaseExceptionEventArgs : AsyncEventArgs
3839
{
3940
///<summary>Wrap an exception thrown by a callback.</summary>
40-
protected BaseExceptionEventArgs(IDictionary<string, object> detail, Exception exception)
41+
protected BaseExceptionEventArgs(IDictionary<string, object> detail, Exception exception, CancellationToken cancellationToken = default)
42+
: base(cancellationToken)
4143
{
4244
Detail = detail;
4345
Exception = exception;
@@ -76,8 +78,8 @@ public class CallbackExceptionEventArgs : BaseExceptionEventArgs
7678
private const string ContextString = "context";
7779
private const string ConsumerString = "consumer";
7880

79-
public CallbackExceptionEventArgs(IDictionary<string, object> detail, Exception exception)
80-
: base(detail, exception)
81+
public CallbackExceptionEventArgs(IDictionary<string, object> detail, Exception exception, CancellationToken cancellationToken = default)
82+
: base(detail, exception, cancellationToken)
8183
{
8284
}
8385

projects/RabbitMQ.Client/client/events/ConnectionBlockedEventArgs.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Threading;
3334

3435
namespace RabbitMQ.Client.Events
3536
{
3637
/// <summary>
3738
/// Event relating to connection being blocked.
3839
/// </summary>
39-
public class ConnectionBlockedEventArgs : EventArgs
40+
public class ConnectionBlockedEventArgs : AsyncEventArgs
4041
{
41-
public ConnectionBlockedEventArgs(string reason)
42+
public ConnectionBlockedEventArgs(string reason, CancellationToken cancellationToken = default)
43+
: base(cancellationToken)
4244
{
4345
Reason = reason;
4446
}

0 commit comments

Comments
 (0)