Skip to content

Commit

Permalink
Cleanup session interface and base
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach committed Sep 19, 2024
1 parent e6e8b5c commit 66f0e41
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
4 changes: 2 additions & 2 deletions projects/RabbitMQ.Client/client/impl/ChannelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ internal async Task FinishCloseAsync(CancellationToken cancellationToken)
ShutdownEventArgs? reason = CloseReason;
if (reason != null)
{
await Session.CloseAsync(reason, cancellationToken)
await Session.CloseAsync(reason)
.ConfigureAwait(false);
}

Expand Down Expand Up @@ -664,7 +664,7 @@ protected async Task<bool> HandleChannelCloseAsync(IncomingCommand cmd, Cancella
channelClose._classId,
channelClose._methodId));

await Session.CloseAsync(_closeReason, false, cancellationToken)
await Session.CloseAsync(_closeReason, notify: false)
.ConfigureAwait(false);

var method = new ChannelCloseOk();
Expand Down
22 changes: 1 addition & 21 deletions projects/RabbitMQ.Client/client/impl/ISession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,19 @@ namespace RabbitMQ.Client.Impl

internal interface ISession
{
/// <summary>
/// Gets the channel number.
/// </summary>
ushort ChannelNumber { get; }

/// <summary>
/// Gets the close reason.
/// </summary>
ShutdownEventArgs? CloseReason { get; }

///<summary>
/// Single recipient - no need for multiple handlers to be informed of arriving commands.
///</summary>
CommandReceivedAction? CommandReceived { get; set; }

/// <summary>
/// Gets the connection.
/// </summary>
Connection Connection { get; }

/// <summary>
/// Gets a value indicating whether this session is open.
/// </summary>
bool IsOpen { get; }

///<summary>
/// Multicast session shutdown event.
///</summary>
event AsyncEventHandler<ShutdownEventArgs> SessionShutdownAsync;

Task CloseAsync(ShutdownEventArgs reason, CancellationToken cancellationToken);

Task CloseAsync(ShutdownEventArgs reason, bool notify, CancellationToken cancellationToken);
Task CloseAsync(ShutdownEventArgs reason, bool notify = true);

Task HandleFrameAsync(InboundFrame frame, CancellationToken cancellationToken);

Expand Down
9 changes: 2 additions & 7 deletions projects/RabbitMQ.Client/client/impl/SessionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ public override string ToString()
return $"{GetType().Name}#{ChannelNumber}:{Connection}";
}

public Task CloseAsync(ShutdownEventArgs reason, CancellationToken cancellationToken)
{
return CloseAsync(reason, true, cancellationToken);
}

public Task CloseAsync(ShutdownEventArgs reason, bool notify, CancellationToken cancellationToken)
public Task CloseAsync(ShutdownEventArgs reason, bool notify = true)
{
if (Interlocked.CompareExchange(ref _closeReason, reason, null) is null)
{
Expand Down Expand Up @@ -155,7 +150,7 @@ public ValueTask TransmitAsync<TMethod, THeader>(in TMethod cmd, in THeader head

private Task OnConnectionShutdownAsync(object? conn, ShutdownEventArgs reason)
{
return CloseAsync(reason, CancellationToken.None);
return CloseAsync(reason);
}

private Task OnSessionShutdownAsync(ShutdownEventArgs reason)
Expand Down

0 comments on commit 66f0e41

Please sign in to comment.