Skip to content

Commit 2323965

Browse files
committed
fix lint
1 parent 6fbfe75 commit 2323965

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

src/Ydb.Sdk/src/Ado/Retry/DefaultRetryPolicy.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ public sealed class DefaultRetryPolicy : IRetryPolicy
55
private readonly RetryConfig _cfg;
66

77
public DefaultRetryPolicy(RetryConfig? config = null)
8-
=> _cfg = config ?? new RetryConfig();
8+
{
9+
_cfg = config ?? new RetryConfig();
10+
}
911

1012
public int MaxAttempts => _cfg.MaxAttempts;
1113

src/Ydb.Sdk/src/Ado/Retry/Delay/DefaultStatusDelayProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public sealed class DefaultStatusDelayProfile : IStatusDelayProfile
77
TimeSpan Calc(TimeSpan baseDelay)
88
{
99
var baseMs = baseDelay.TotalMilliseconds * Math.Pow(2.0, attempt - 1);
10-
var jitter = 1.0 + (Random.Shared.NextDouble() * 0.5);
10+
var jitter = 1.0 + Random.Shared.NextDouble() * 0.5;
1111
var ms = Math.Min(baseMs * jitter, TimeSpan.FromSeconds(10).TotalMilliseconds);
1212
return TimeSpan.FromMilliseconds(ms);
1313
}

src/Ydb.Sdk/src/Ado/Retry/RetryConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class RetryConfig
2222
static (_, attempt) =>
2323
{
2424
var baseMs = 100.0 * Math.Pow(2.0, Math.Max(0, attempt - 1));
25-
var jitter = 1.0 + (Random.Shared.NextDouble() * 0.5);
25+
var jitter = 1.0 + Random.Shared.NextDouble() * 0.5;
2626
var ms = Math.Min(baseMs * jitter, 10_000.0);
2727
return TimeSpan.FromMilliseconds(ms);
2828
};

src/Ydb.Sdk/test/Ydb.Sdk.Ado.Tests/DefaultRetryPolicyTests.cs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Data;
21
using Xunit;
32
using Ydb.Sdk.Ado.Retry;
43

@@ -11,7 +10,7 @@ public void GetDelay_WhenAttemptOne_UsesDefaultDelayDelegate()
1110
{
1211
var config = new RetryConfig
1312
{
14-
DefaultDelay = (_, __) => TimeSpan.FromMilliseconds(100),
13+
DefaultDelay = (_ex, _attempt) => TimeSpan.FromMilliseconds(100),
1514
MaxDelay = TimeSpan.FromMilliseconds(500)
1615
};
1716

@@ -20,7 +19,7 @@ public void GetDelay_WhenAttemptOne_UsesDefaultDelayDelegate()
2019
var delay = policy.GetDelay(new Exception("test"), 1);
2120
Assert.Equal(TimeSpan.FromMilliseconds(100), delay);
2221
}
23-
22+
2423
[Fact]
2524
public void GetDelay_WhenAttemptOne_ReturnsBaseDelay_NoJitter()
2625
{
@@ -49,7 +48,7 @@ public void GetDelay_WhenAttemptOne_ReturnsBaseDelay_NoJitter()
4948
public void GetDelay_WhenStatusHasOverride_ReturnsPerStatusDelay()
5049
{
5150
var config = new RetryConfig();
52-
config.PerStatusDelay[StatusCode.Unavailable] = attempt => TimeSpan.FromMilliseconds(123);
51+
config.PerStatusDelay[StatusCode.Unavailable] = _attempt => TimeSpan.FromMilliseconds(123);
5352
var policy = new DefaultRetryPolicy(config);
5453

5554
var ex = new YdbException(StatusCode.Unavailable, "unavailable");
@@ -98,7 +97,7 @@ public void CanRetry_WhenUserCancelled_ReturnsFalse()
9897
var ex = new OperationCanceledException(cts.Token);
9998
Assert.False(policy.CanRetry(ex, isIdempotent: true));
10099
}
101-
100+
102101
[Fact]
103102
public void GetDelay_WhenDelayExceedsMaxDelay_IsCappedToMaxDelay()
104103
{
@@ -123,22 +122,4 @@ public void CanRetry_WhenOperationCanceledWithoutToken_ReturnsFalse()
123122
var ex = new OperationCanceledException();
124123
Assert.False(policy.CanRetry(ex, isIdempotent: true));
125124
}
126-
127-
private class DummyCommand : System.Data.Common.DbCommand
128-
{
129-
public override string CommandText { get; set; } = string.Empty;
130-
public override int CommandTimeout { get; set; }
131-
public override CommandType CommandType { get; set; } = CommandType.Text;
132-
protected override System.Data.Common.DbConnection DbConnection { get; set; }
133-
protected override System.Data.Common.DbParameterCollection DbParameterCollection { get; } = null!;
134-
protected override System.Data.Common.DbTransaction DbTransaction { get; set; }
135-
public override bool DesignTimeVisible { get; set; }
136-
public override UpdateRowSource UpdatedRowSource { get; set; }
137-
public override void Cancel() { }
138-
public override int ExecuteNonQuery() => 0;
139-
public override object ExecuteScalar() => null!;
140-
public override void Prepare() { }
141-
protected override System.Data.Common.DbParameter CreateDbParameter() => throw new NotImplementedException();
142-
protected override System.Data.Common.DbDataReader ExecuteDbDataReader(CommandBehavior behavior) => throw new NotImplementedException();
143-
}
144125
}

0 commit comments

Comments
 (0)