Skip to content

Commit dfcc183

Browse files
committed
Use constants
1 parent 23f6613 commit dfcc183

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ TestResult.xml
1919
/NuGet
2020
.vscode/
2121
*.lock.json
22-
api/
2322

2423
test.sh
2524
*.VisualState.xml

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class IConnectionExtensions
1919
/// </remarks>
2020
public static void Close(this IConnection connection)
2121
{
22-
connection.Close(Constants.ReplySuccess, "Goodbye", TimeSpan.FromSeconds(30), false);
22+
connection.Close(Constants.ReplySuccess, "Goodbye", InternalConstants.DefaultConnectionCloseTimeout, false);
2323
}
2424

2525
/// <summary>
@@ -37,7 +37,7 @@ public static void Close(this IConnection connection)
3737
/// </remarks>
3838
public static void Close(this IConnection connection, ushort reasonCode, string reasonText)
3939
{
40-
connection.Close(reasonCode, reasonText, TimeSpan.FromSeconds(30), false);
40+
connection.Close(reasonCode, reasonText, InternalConstants.DefaultConnectionCloseTimeout, false);
4141
}
4242

4343
/// <summary>
@@ -93,7 +93,7 @@ public static void Close(this IConnection connection, ushort reasonCode, string
9393
/// </remarks>
9494
public static void Abort(this IConnection connection)
9595
{
96-
connection.Close(Constants.ReplySuccess, "Connection close forced", TimeSpan.FromSeconds(5), true);
96+
connection.Close(Constants.ReplySuccess, "Connection close forced", InternalConstants.DefaultConnectionAbortTimeout, true);
9797
}
9898

9999
/// <summary>
@@ -111,7 +111,7 @@ public static void Abort(this IConnection connection)
111111
/// </remarks>
112112
public static void Abort(this IConnection connection, ushort reasonCode, string reasonText)
113113
{
114-
connection.Close(reasonCode, reasonText, TimeSpan.FromSeconds(5), true);
114+
connection.Close(reasonCode, reasonText, InternalConstants.DefaultConnectionAbortTimeout, true);
115115
}
116116

117117
/// <summary>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// This source code is dual-licensed under the Apache License, version
2+
// 2.0, and the Mozilla Public License, version 2.0.
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 v2.0:
23+
//
24+
//---------------------------------------------------------------------------
25+
// This Source Code Form is subject to the terms of the Mozilla Public
26+
// License, v. 2.0. If a copy of the MPL was not distributed with this
27+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
28+
//
29+
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
30+
//---------------------------------------------------------------------------
31+
32+
using System;
33+
34+
namespace RabbitMQ.Client
35+
{
36+
internal static class InternalConstants
37+
{
38+
internal static readonly TimeSpan DefaultConnectionAbortTimeout = TimeSpan.FromSeconds(5);
39+
internal static readonly TimeSpan DefaultConnectionCloseTimeout = TimeSpan.FromSeconds(30);
40+
}
41+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void Dispose()
216216

217217
try
218218
{
219-
this.Abort(TimeSpan.FromSeconds(15));
219+
this.Abort(InternalConstants.DefaultConnectionAbortTimeout);
220220
}
221221
catch (Exception)
222222
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public void Dispose()
410410

411411
try
412412
{
413-
this.Abort(TimeSpan.FromSeconds(15));
413+
this.Abort(InternalConstants.DefaultConnectionAbortTimeout);
414414
_mainLoopTask.Wait();
415415
}
416416
catch (OperationInterruptedException)

projects/RabbitMQ.Client/client/impl/ModelBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ protected void HandleConnectionStart(in IncomingCommand cmd)
742742
if (m_connectionStartCell is null)
743743
{
744744
var reason = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.CommandInvalid, "Unexpected Connection.Start");
745-
Session.Connection.Close(reason, false, TimeSpan.FromSeconds(30));
745+
Session.Connection.Close(reason, false, InternalConstants.DefaultConnectionCloseTimeout);
746746
}
747747

748748
var method = new ConnectionStart(cmd.MethodBytes.Span);

0 commit comments

Comments
 (0)