1
0
mirror of synced 2024-09-28 19:56:09 +00:00
Tapeti/Tapeti/IConnection.cs
Mark van Renswoude f8fca5879c [ci skip] Major refactoring for 2.0
- Compiles, but that's about it. Plenty of ToDo's left before it will run. Beware, ye who enter here.
- Cleanup of the internals, with the aim to keep the interface to application code compatible
- Added the ability to declare durable queues on startup and update the bindings
- Possibly fixed an issue with publish timeouts being logged after a reconnect
2019-08-13 20:30:04 +02:00

81 lines
2.5 KiB
C#

using System;
using System.Threading.Tasks;
// ReSharper disable UnusedMember.Global
namespace Tapeti
{
/// <summary>
/// Contains information about the reason for a lost connection.
/// </summary>
public class DisconnectedEventArgs
{
/// <summary>
/// The ReplyCode as indicated by the client library
/// </summary>
public ushort ReplyCode;
/// <summary>
/// The ReplyText as indicated by the client library
/// </summary>
public string ReplyText;
}
/// <inheritdoc />
public delegate void DisconnectedEventHandler(object sender, DisconnectedEventArgs e);
/// <inheritdoc />
/// <summary>
/// Represents a connection to a RabbitMQ server
/// </summary>
public interface IConnection : IDisposable
{
/// <summary>
/// Creates a subscriber to consume messages from the bound queues.
/// </summary>
/// <param name="startConsuming">If true, the subscriber will start consuming messages immediately. If false, the queues will be
/// declared but no messages will be consumed yet. Call Resume on the returned ISubscriber to start consuming messages.</param>
Task<ISubscriber> Subscribe(bool startConsuming = true);
/// <summary>
/// Synchronous version of Subscribe.
/// </summary>
/// <param name="startConsuming">If true, the subscriber will start consuming messages immediately. If false, the queues will be
/// declared but no messages will be consumed yet. Call Resume on the returned ISubscriber to start consuming messages.</param>
ISubscriber SubscribeSync(bool startConsuming = true);
/// <summary>
/// Returns an IPublisher implementation for the current connection.
/// </summary>
/// <returns></returns>
IPublisher GetPublisher();
/// <summary>
/// Closes the connection to RabbitMQ.
/// </summary>
Task Close();
/// <summary>
/// Fired when a connection to RabbitMQ has been established.
/// </summary>
event EventHandler Connected;
/// <summary>
/// Fired when the connection to RabbitMQ has been lost.
/// </summary>
event DisconnectedEventHandler Disconnected;
/// <summary>
/// Fired when the connection to RabbitMQ has been recovered after an unexpected disconnect.
/// </summary>
event EventHandler Reconnected;
}
}