-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SqlStatementExecution with exponential backoff (#346)
Introduces an exponential backoff strategy for retrieving response from Databricks SQL Statement Execution API
- Loading branch information
1 parent
081d6e8
commit 64627d4
Showing
6 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
source/Databricks/source/SqlStatementExecution.UnitTests/FibonacciTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2020 Energinet DataHub A/S | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License2"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Energinet.DataHub.Core.Databricks.SqlStatementExecution.UnitTests; | ||
|
||
public class FibonacciTests | ||
{ | ||
[Fact] | ||
public void GetNextNumber_WhenCalled_ReturnsNextNumberInSequence() | ||
{ | ||
// Arrange | ||
var fibonacci = new Fibonacci(); | ||
var result = 0; | ||
|
||
// Act | ||
for (int i = 0; i < 5; i++) | ||
{ | ||
result = fibonacci.GetNextNumber(); | ||
} | ||
|
||
// Assert | ||
Assert.Equal(8, result); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
source/Databricks/source/SqlStatementExecution/Fibonacci.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2020 Energinet DataHub A/S | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License2"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Energinet.DataHub.Core.Databricks.SqlStatementExecution; | ||
|
||
internal sealed class Fibonacci | ||
{ | ||
private int _firstNumber; | ||
private int _secondNumber = 1; | ||
|
||
/// <summary> | ||
/// Get the next number in the Fibonacci sequence. | ||
/// </summary> | ||
public int GetNextNumber() | ||
{ | ||
var result = _firstNumber + _secondNumber; | ||
_firstNumber = _secondNumber; | ||
_secondNumber = result; | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters