Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part 1 of #1308 - renaming IModel and related names #1309

Merged
merged 4 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void IBasicConsumer.HandleBasicDeliver(string consumerTag, ulong deliveryTag, bo

public Task HandleBasicConsumeOk(string consumerTag) => Task.CompletedTask;

public Task HandleModelShutdown(object model, ShutdownEventArgs reason) => Task.CompletedTask;
public Task HandleChannelShutdown(object channel, ShutdownEventArgs reason) => Task.CompletedTask;

public IModel Model { get; }
public IChannel Channel { get; }

event EventHandler<ConsumerEventArgs> IBasicConsumer.ConsumerCancelled
{
Expand All @@ -68,7 +68,7 @@ void IBasicConsumer.HandleBasicConsumeOk(string consumerTag)
{
}

void IBasicConsumer.HandleModelShutdown(object model, ShutdownEventArgs reason)
void IBasicConsumer.HandleChannelShutdown(object channel, ShutdownEventArgs reason)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ public class Networking_BasicDeliver_Commons
public static async Task Publish_Hello_World(IConnection connection, uint messageCount, byte[] body)
{
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
using (var model = connection.CreateModel())
using (var channel = connection.CreateChannel())
{
var queue = model.QueueDeclare();
var queue = channel.QueueDeclare();
var consumed = 0;
var consumer = new EventingBasicConsumer(model);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (s, args) =>
{
if (Interlocked.Increment(ref consumed) == messageCount)
{
tcs.SetResult(true);
}
};
model.BasicConsume(queue.QueueName, true, consumer);
channel.BasicConsume(queue.QueueName, true, consumer);

for (int i = 0; i < messageCount; i++)
{
model.BasicPublish("", queue.QueueName, body);
channel.BasicPublish("", queue.QueueName, body);
}

await tcs.Task;
Expand Down
26 changes: 13 additions & 13 deletions projects/RabbitMQ.Client/client/api/AsyncDefaultBasicConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public AsyncDefaultBasicConsumer()
}

/// <summary>
/// Constructor which sets the Model property to the given value.
/// Constructor which sets the Channel property to the given value.
/// </summary>
/// <param name="model">Common AMQP model.</param>
public AsyncDefaultBasicConsumer(IModel model)
/// <param name="channel">Common AMQP channel.</param>
public AsyncDefaultBasicConsumer(IChannel channel)
{
Model = model;
Channel = channel;
}

/// <summary>
/// Retrieve the consumer tags this consumer is registered as; to be used when discussing this consumer
/// with the server, for instance with <see cref="IModel.BasicCancel"/>.
/// with the server, for instance with <see cref="IChannel.BasicCancel"/>.
/// </summary>
public string[] ConsumerTags
{
Expand All @@ -45,7 +45,7 @@ public string[] ConsumerTags
public bool IsRunning { get; protected set; }

/// <summary>
/// If our <see cref="IModel"/> shuts down, this property will contain a description of the reason for the
/// If our <see cref="IChannel"/> shuts down, this property will contain a description of the reason for the
/// shutdown. Otherwise it will contain null. See <see cref="ShutdownEventArgs"/>.
/// </summary>
public ShutdownEventArgs ShutdownReason { get; protected set; }
Expand All @@ -61,10 +61,10 @@ public event AsyncEventHandler<ConsumerEventArgs> ConsumerCancelled
private AsyncEventingWrapper<ConsumerEventArgs> _consumerCancelledWrapper;

/// <summary>
/// Retrieve the <see cref="IModel"/> this consumer is associated with,
/// Retrieve the <see cref="IChannel"/> this consumer is associated with,
/// for use in acknowledging received messages, for instance.
/// </summary>
public IModel Model { get; set; }
public IChannel Channel { get; set; }

/// <summary>
/// Called when the consumer is cancelled for reasons other than by a basicCancel:
Expand Down Expand Up @@ -101,7 +101,7 @@ public virtual Task HandleBasicConsumeOk(string consumerTag)
/// Called each time a message is delivered for this consumer.
/// </summary>
/// <remarks>
/// This is a no-op implementation. It will not acknowledge deliveries via <see cref="IModel.BasicAck"/>
/// This is a no-op implementation. It will not acknowledge deliveries via <see cref="IChannel.BasicAck"/>
/// if consuming in automatic acknowledgement mode.
/// Subclasses must copy or fully use delivery body before returning.
/// Accessing the body at a later point is unsafe as its memory can
Expand All @@ -120,11 +120,11 @@ public virtual Task HandleBasicDeliver(string consumerTag,
}

/// <summary>
/// Called when the model (channel) this consumer was registered on terminates.
/// Called when the channel (channel) this consumer was registered on terminates.
/// </summary>
/// <param name="model">A channel this consumer was registered on.</param>
/// <param name="channel">A channel this consumer was registered on.</param>
/// <param name="reason">Shutdown context.</param>
public virtual Task HandleModelShutdown(object model, ShutdownEventArgs reason)
public virtual Task HandleChannelShutdown(object channel, ShutdownEventArgs reason)
{
ShutdownReason = reason;
return OnCancel(_consumerTags.ToArray());
Expand Down Expand Up @@ -170,7 +170,7 @@ void IBasicConsumer.HandleBasicDeliver(string consumerTag, ulong deliveryTag, bo
throw new InvalidOperationException("Should never be called. Enable 'DispatchConsumersAsync'.");
}

void IBasicConsumer.HandleModelShutdown(object model, ShutdownEventArgs reason)
void IBasicConsumer.HandleChannelShutdown(object channel, ShutdownEventArgs reason)
{
throw new InvalidOperationException("Should never be called. Enable 'DispatchConsumersAsync'.");
}
Expand Down
2 changes: 1 addition & 1 deletion projects/RabbitMQ.Client/client/api/BasicGetResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public BasicGetResult(ulong deliveryTag, bool redelivered, string exchange, stri
public ReadOnlyMemory<byte> Body { get; }

/// <summary>
/// Retrieve the delivery tag for this message. See also <see cref="IModel.BasicAck"/>.
/// Retrieve the delivery tag for this message. See also <see cref="IChannel.BasicAck"/>.
/// </summary>
public ulong DeliveryTag { get; }

Expand Down
2 changes: 1 addition & 1 deletion projects/RabbitMQ.Client/client/api/CachedString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace RabbitMQ.Client
{
/// <summary>
/// Caches a string's byte representation to be used for certain methods like IModel.BasicPublish/>.
/// Caches a string's byte representation to be used for certain methods like IChannel.BasicPublish/>.
/// </summary>
public sealed class CachedString
{
Expand Down
4 changes: 2 additions & 2 deletions projects/RabbitMQ.Client/client/api/ConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ namespace RabbitMQ.Client
/// //
/// IConnection conn = factory.CreateConnection();
/// //
/// IModel ch = conn.CreateModel();
/// IChannel ch = conn.CreateChannel();
/// //
/// // ... use ch's IModel methods ...
/// // ... use ch's IChannel methods ...
/// //
/// ch.Close(Constants.ReplySuccess, "Closing the channel");
/// conn.Close(Constants.ReplySuccess, "Closing the connection");
Expand Down
24 changes: 12 additions & 12 deletions projects/RabbitMQ.Client/client/api/DefaultBasicConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ public DefaultBasicConsumer()
}

/// <summary>
/// Constructor which sets the Model property to the given value.
/// Constructor which sets the Channel property to the given value.
/// </summary>
/// <param name="model">Common AMQP model.</param>
public DefaultBasicConsumer(IModel model)
/// <param name="channel">Common AMQP channel.</param>
public DefaultBasicConsumer(IChannel channel)
{
Model = model;
Channel = channel;
}

/// <summary>
/// Retrieve the consumer tags this consumer is registered as; to be used to identify
/// this consumer, for example, when cancelling it with <see cref="IModel.BasicCancel"/>.
/// this consumer, for example, when cancelling it with <see cref="IChannel.BasicCancel"/>.
/// This value is an array because a single consumer instance can be reused to consume on
/// multiple channels.
/// </summary>
Expand All @@ -86,7 +86,7 @@ public string[] ConsumerTags
public bool IsRunning { get; protected set; }

/// <summary>
/// If our <see cref="IModel"/> shuts down, this property will contain a description of the reason for the
/// If our <see cref="IChannel"/> shuts down, this property will contain a description of the reason for the
/// shutdown. Otherwise it will contain null. See <see cref="ShutdownEventArgs"/>.
/// </summary>
public ShutdownEventArgs ShutdownReason { get; protected set; }
Expand All @@ -102,10 +102,10 @@ public event EventHandler<ConsumerEventArgs> ConsumerCancelled
private EventingWrapper<ConsumerEventArgs> _consumerCancelledWrapper;

/// <summary>
/// Retrieve the <see cref="IModel"/> this consumer is associated with,
/// Retrieve the <see cref="IChannel"/> this consumer is associated with,
/// for use in acknowledging received messages, for instance.
/// </summary>
public IModel Model { get; set; }
public IChannel Channel { get; set; }

/// <summary>
/// Called when the consumer is cancelled for reasons other than by a basicCancel:
Expand Down Expand Up @@ -141,7 +141,7 @@ public virtual void HandleBasicConsumeOk(string consumerTag)
/// Called each time a message is delivered for this consumer.
/// </summary>
/// <remarks>
/// This is a no-op implementation. It will not acknowledge deliveries via <see cref="IModel.BasicAck"/>
/// This is a no-op implementation. It will not acknowledge deliveries via <see cref="IChannel.BasicAck"/>
/// if consuming in automatic acknowledgement mode.
/// Subclasses must copy or fully use delivery body before returning.
/// Accessing the body at a later point is unsafe as its memory can
Expand All @@ -159,11 +159,11 @@ public virtual void HandleBasicDeliver(string consumerTag,
}

/// <summary>
/// Called when the model (channel) this consumer was registered on terminates.
/// Called when the channel (channel) this consumer was registered on terminates.
/// </summary>
/// <param name="model">A channel this consumer was registered on.</param>
/// <param name="channel">A channel this consumer was registered on.</param>
/// <param name="reason">Shutdown context.</param>
public virtual void HandleModelShutdown(object model, ShutdownEventArgs reason)
public virtual void HandleChannelShutdown(object channel, ShutdownEventArgs reason)
{
ShutdownReason = reason;
OnCancel(_consumerTags.ToArray());
Expand Down
2 changes: 1 addition & 1 deletion projects/RabbitMQ.Client/client/api/ExchangeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace RabbitMQ.Client
/// </summary>
/// <remarks>
/// Use the static members of this class as values for the
/// "exchangeType" arguments for IModel methods such as
/// "exchangeType" arguments for IChannel methods such as
/// ExchangeDeclare. The broker may be extended with additional
/// exchange types that do not appear in this class.
/// </remarks>
Expand Down
14 changes: 7 additions & 7 deletions projects/RabbitMQ.Client/client/api/IAsyncBasicConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace RabbitMQ.Client
public interface IAsyncBasicConsumer
{
/// <summary>
/// Retrieve the <see cref="IModel"/> this consumer is associated with,
/// Retrieve the <see cref="IChannel"/> this consumer is associated with,
/// for use in acknowledging received messages, for instance.
/// </summary>
IModel Model { get; }
IChannel Channel { get; }

/// <summary>
/// Signalled when the consumer gets cancelled.
Expand Down Expand Up @@ -43,7 +43,7 @@ public interface IAsyncBasicConsumer
/// </summary>
/// <remarks>
/// Does nothing with the passed in information.
/// Note that in particular, some delivered messages may require acknowledgement via <see cref="IModel.BasicAck"/>.
/// Note that in particular, some delivered messages may require acknowledgement via <see cref="IChannel.BasicAck"/>.
/// The implementation of this method in this class does NOT acknowledge such messages.
/// </remarks>
Task HandleBasicDeliver(string consumerTag,
Expand All @@ -55,10 +55,10 @@ Task HandleBasicDeliver(string consumerTag,
ReadOnlyMemory<byte> body);

/// <summary>
/// Called when the model shuts down.
/// Called when the channel shuts down.
/// </summary>
/// <param name="model"> Common AMQP model.</param>
/// <param name="reason"> Information about the reason why a particular model, session, or connection was destroyed.</param>
Task HandleModelShutdown(object model, ShutdownEventArgs reason);
/// <param name="channel"> Common AMQP channel.</param>
/// <param name="reason"> Information about the reason why a particular channel, session, or connection was destroyed.</param>
Task HandleChannelShutdown(object channel, ShutdownEventArgs reason);
}
}
16 changes: 8 additions & 8 deletions projects/RabbitMQ.Client/client/api/IBasicConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace RabbitMQ.Client
///receive messages from a queue by subscription.</summary>
/// <remarks>
/// <para>
/// See IModel.BasicConsume, IModel.BasicCancel.
/// See IChannel.BasicConsume, IChannel.BasicCancel.
/// </para>
/// <para>
/// Note that the "Handle*" methods run in the connection's
Expand All @@ -51,10 +51,10 @@ namespace RabbitMQ.Client
public interface IBasicConsumer
{
/// <summary>
/// Retrieve the <see cref="IModel"/> this consumer is associated with,
/// Retrieve the <see cref="IChannel"/> this consumer is associated with,
/// for use in acknowledging received messages, for instance.
/// </summary>
IModel Model { get; }
IChannel Channel { get; }

/// <summary>
/// Signalled when the consumer gets cancelled.
Expand Down Expand Up @@ -86,7 +86,7 @@ public interface IBasicConsumer
/// </summary>
/// <remarks>
/// Does nothing with the passed in information.
/// Note that in particular, some delivered messages may require acknowledgement via <see cref="IModel.BasicAck"/>.
/// Note that in particular, some delivered messages may require acknowledgement via <see cref="IChannel.BasicAck"/>.
/// The implementation of this method in this class does NOT acknowledge such messages.
/// </remarks>
void HandleBasicDeliver(string consumerTag,
Expand All @@ -98,10 +98,10 @@ void HandleBasicDeliver(string consumerTag,
ReadOnlyMemory<byte> body);

/// <summary>
/// Called when the model shuts down.
/// Called when the channel shuts down.
/// </summary>
/// <param name="model"> Common AMQP model.</param>
/// <param name="reason"> Information about the reason why a particular model, session, or connection was destroyed.</param>
void HandleModelShutdown(object model, ShutdownEventArgs reason);
/// <param name="channel"> Common AMQP channel.</param>
/// <param name="reason"> Information about the reason why a particular channel, session, or connection was destroyed.</param>
void HandleChannelShutdown(object channel, ShutdownEventArgs reason);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace RabbitMQ.Client
/// Extends the <see cref="IDisposable"/> interface, so that the "using"
/// statement can be used to scope the lifetime of a channel when appropriate.
/// </remarks>
public interface IModel : IDisposable
public interface IChannel : IDisposable
{
/// <summary>
/// Channel number, unique per connections.
Expand Down Expand Up @@ -83,12 +83,12 @@ public interface IModel : IDisposable
IBasicConsumer DefaultConsumer { get; set; }

/// <summary>
/// Returns true if the model is no longer in a state where it can be used.
/// Returns true if the channel is no longer in a state where it can be used.
/// </summary>
bool IsClosed { get; }

/// <summary>
/// Returns true if the model is still in a state where it can be used.
/// Returns true if the channel is still in a state where it can be used.
/// Identical to checking if <see cref="CloseReason"/> equals null.</summary>
bool IsOpen { get; }

Expand Down Expand Up @@ -124,24 +124,24 @@ public interface IModel : IDisposable
event EventHandler<BasicReturnEventArgs> BasicReturn;

/// <summary>
/// Signalled when an exception occurs in a callback invoked by the model.
/// Signalled when an exception occurs in a callback invoked by the channel.
///
/// Examples of cases where this event will be signalled
/// include exceptions thrown in <see cref="IBasicConsumer"/> methods, or
/// exceptions thrown in <see cref="ModelShutdown"/> delegates etc.
/// exceptions thrown in <see cref="ChannelShutdown"/> delegates etc.
/// </summary>
event EventHandler<CallbackExceptionEventArgs> CallbackException;

event EventHandler<FlowControlEventArgs> FlowControl;

/// <summary>
/// Notifies the destruction of the model.
/// Notifies the destruction of the channel.
/// </summary>
/// <remarks>
/// If the model is already destroyed at the time an event
/// If the channel is already destroyed at the time an event
/// handler is added to this event, the event handler will be fired immediately.
/// </remarks>
event EventHandler<ShutdownEventArgs> ModelShutdown;
event EventHandler<ShutdownEventArgs> ChannelShutdown;

/// <summary>
/// Acknowledge one or more delivered message(s).
Expand Down Expand Up @@ -172,7 +172,7 @@ string BasicConsume(
/// <summary>
/// Retrieve an individual message, if
/// one is available; returns null if the server answers that
/// no messages are currently available. See also <see cref="IModel.BasicAck"/>.
/// no messages are currently available. See also <see cref="IChannel.BasicAck"/>.
/// </summary>
BasicGetResult BasicGet(string queue, bool autoAck);

Expand Down
Loading