Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
David R. Williamson committed Apr 20, 2023
1 parent fcd79d3 commit ff3f15b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions iothub/device/src/Pipeline/AmqpTransportHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ internal class AmqpTransportHandler : TransportHandlerBase

internal IotHubConnectionCredentials _connectionCredentials;

private static readonly TimeSpan s_twinResponseTimeout = TimeSpan.FromMinutes(2);
private bool _closed;

static AmqpTransportHandler()
Expand Down Expand Up @@ -527,7 +526,7 @@ private void RemoveOldOperations(object state)
{
if (state is not TimeSpan maxAge)
{
maxAge = s_twinResponseTimeout;
maxAge = TwinResponseTimeout;
}

if (Logging.IsEnabled)
Expand Down
6 changes: 2 additions & 4 deletions iothub/device/src/Pipeline/MqttTransportHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ internal sealed class MqttTransportHandler : TransportHandlerBase, IDisposable
// Timer to check if any expired messages exist. The timer is executed after each hour of execution.
private readonly Timer _twinTimeoutTimer;

private static TimeSpan s_twinResponseTimeout = TimeSpan.FromMinutes(2);

private bool _isSubscribedToTwinResponses;

private readonly string _deviceId;
Expand Down Expand Up @@ -313,7 +311,7 @@ public override async Task OpenAsync(CancellationToken cancellationToken)
_mqttClient.ApplicationMessageReceivedAsync += HandleReceivedMessageAsync;

// The timer would invoke callback in the specified time and that duration thereafter.
_twinTimeoutTimer.Change(s_twinResponseTimeout, s_twinResponseTimeout);
_twinTimeoutTimer.Change(TwinResponseTimeout, TwinResponseTimeout);
}
catch (MqttConnectingFailedException ex)
{
Expand Down Expand Up @@ -1355,7 +1353,7 @@ private void RemoveOldOperations(object state)
{
if (state is not TimeSpan maxAge)
{
maxAge = s_twinResponseTimeout;
maxAge = TwinResponseTimeout;
}

if (Logging.IsEnabled)
Expand Down
3 changes: 3 additions & 0 deletions iothub/device/src/Pipeline/TransportHandlerBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Threading.Tasks;

namespace Microsoft.Azure.Devices.Client.Transport
Expand All @@ -17,6 +18,8 @@ protected TransportHandlerBase(PipelineContext context, IDelegatingHandler nextH
{
}

protected static TimeSpan TwinResponseTimeout { get; } = TimeSpan.FromHours(1);

public override Task WaitForTransportClosedAsync()
{
_transportShouldRetry = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private SystemTextJsonPayloadConvention() { }
/// <summary>
/// A static instance of this class.
/// </summary>
public static SystemTextJsonPayloadConvention Instance => new();
public static SystemTextJsonPayloadConvention Instance { get; } = new();

/// <inheritdoc/>
public override string ContentType => "application/json";
Expand Down

0 comments on commit ff3f15b

Please sign in to comment.