Skip to content

Commit 1469ce9

Browse files
committed
Remove Interrupted(StoredId) method from IFunctionStore
Replace test usages with GetInterruptedFunctions() and GetFunction(). The method was only used in tests and is now redundant.
1 parent 82a230e commit 1469ce9

8 files changed

Lines changed: 5 additions & 80 deletions

File tree

Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,14 +689,14 @@ public async Task RestartingFunctionShouldSetInterruptedToFalse(Task<IFunctionSt
689689
session.ShouldBeNull();
690690

691691
await store.Interrupt(functionId).ShouldBeTrueAsync();
692-
await store.Interrupted(functionId).ShouldBeAsync(true);
692+
(await store.GetInterruptedFunctions()).Any(id => id == functionId).ShouldBeTrue();
693693

694694
await store.RestartExecution(
695-
functionId,
695+
functionId,
696696
owner: ReplicaId.NewId()
697697
).ShouldNotBeNullAsync();
698-
699-
await store.Interrupted(functionId).ShouldBeAsync(false);
698+
699+
(await store.GetInterruptedFunctions()).Any(id => id == functionId).ShouldBeFalse();
700700
}
701701

702702
public abstract Task MessagesCanBeFetchedAfterFunctionWithInitialMessagesHasBeenCreated();
@@ -1039,7 +1039,7 @@ protected async Task InterruptCountForNonExistingFunctionIsNull(Task<IFunctionSt
10391039
{
10401040
var functionId = TestStoredId.Create();
10411041
var store = await storeTask;
1042-
(await store.Interrupted(functionId)).ShouldBeNull();
1042+
(await store.GetFunction(functionId)).ShouldBeNull();
10431043
}
10441044

10451045
public abstract Task DefaultStateCanSetAndFetchedAfterwards();

Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/WatchDogsTests/CrashableFunctionStore.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ public Task<bool> Interrupt(StoredId storedId)
189189

190190
public Task ResetInterrupted(IReadOnlyList<StoredId> storedIds) => _inner.ResetInterrupted(storedIds);
191191

192-
public Task<bool?> Interrupted(StoredId storedId)
193-
=> _crashed
194-
? Task.FromException<bool?>(new TimeoutException())
195-
: _inner.Interrupted(storedId);
196-
197192
public Task<bool> SetParameters(StoredId storedId, byte[]? storedParameter, byte[]? storedResult, ReplicaId? expectedReplica)
198193
=> _crashed
199194
? Task.FromException<bool>(new TimeoutException())

Core/Cleipnir.ResilientFunctions/Storage/IFunctionStore.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Task<bool> SuspendFunction(
105105
Task<bool> Interrupt(StoredId storedId);
106106
Task Interrupt(IReadOnlyList<StoredId> storedIds);
107107
Task ResetInterrupted(IReadOnlyList<StoredId> storedIds);
108-
Task<bool?> Interrupted(StoredId storedId);
109108

110109
Task<Status?> GetFunctionStatus(StoredId storedId);
111110
Task<IReadOnlyList<StatusAndId>> GetFunctionsStatus(IEnumerable<StoredId> storedIds);

Core/Cleipnir.ResilientFunctions/Storage/InMemoryFunctionStore.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,6 @@ public Task ResetInterrupted(IReadOnlyList<StoredId> storedIds)
462462
return Task.CompletedTask;
463463
}
464464

465-
public Task<bool?> Interrupted(StoredId storedId)
466-
{
467-
lock (_sync)
468-
{
469-
if (!_states.ContainsKey(storedId))
470-
return Task.FromResult(default(bool?));
471-
472-
return ((bool?) _states[storedId].Interrupted).ToTask();
473-
}
474-
}
475-
476465
public Task<Status?> GetFunctionStatus(StoredId storedId)
477466
{
478467
lock (_sync)

Samples/Sample.ConsoleApp/Utils/CrashableFunctionStore.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ public Task ResetInterrupted(IReadOnlyList<StoredId> storedIds)
175175
? Task.FromException(new TimeoutException())
176176
: _inner.ResetInterrupted(storedIds);
177177

178-
public Task<bool?> Interrupted(StoredId storedId)
179-
=> _crashed
180-
? Task.FromException<bool?>(new TimeoutException())
181-
: _inner.Interrupted(storedId);
182-
183178
public Task<Status?> GetFunctionStatus(StoredId storedId)
184179
=> _crashed
185180
? Task.FromException<Status?>(new TimeoutException())

Stores/MariaDB/Cleipnir.ResilientFunctions.MariaDB/MariaDbFunctionStore.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -719,26 +719,6 @@ public async Task<bool> SetParameters(
719719
return affectedRows == 1;
720720
}
721721

722-
private string? _getInterruptCountSql;
723-
public async Task<bool?> Interrupted(StoredId storedId)
724-
{
725-
await using var conn = await CreateOpenConnection(_connectionString);
726-
727-
_getInterruptCountSql ??= $@"
728-
SELECT interrupted
729-
FROM {_tablePrefix}
730-
WHERE id = ?;";
731-
732-
await using var command = new MySqlCommand(_getInterruptCountSql, conn)
733-
{
734-
Parameters =
735-
{
736-
new() { Value = storedId.AsGuid.ToString("N") },
737-
}
738-
};
739-
740-
return (bool?) await command.ExecuteScalarAsync();
741-
}
742722

743723
private string? _getFunctionStatusSql;
744724
public async Task<Status?> GetFunctionStatus(StoredId storedId)

Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL/PostgreSqlFunctionStore.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -684,24 +684,6 @@ public async Task ResetInterrupted(IReadOnlyList<StoredId> storedIds)
684684
await command.ExecuteNonQueryAsync();
685685
}
686686

687-
private string? _interruptedSql;
688-
public async Task<bool?> Interrupted(StoredId storedId)
689-
{
690-
await using var conn = await CreateConnection();
691-
692-
_interruptedSql ??= $@"
693-
SELECT interrupted
694-
FROM {_tableName}
695-
WHERE id = $1";
696-
await using var command = new NpgsqlCommand(_interruptedSql, conn)
697-
{
698-
Parameters =
699-
{
700-
new() { Value = storedId.AsGuid },
701-
}
702-
};
703-
return (bool?) await command.ExecuteScalarAsync();
704-
}
705687

706688
private string? _getFunctionStatusSql;
707689
public async Task<Status?> GetFunctionStatus(StoredId storedId)

Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -772,22 +772,7 @@ public async Task<bool> SetParameters(
772772
var affectedRows = await command.ExecuteNonQueryAsync();
773773
return affectedRows > 0;
774774
}
775-
776-
private string? _interruptedSql;
777-
public async Task<bool?> Interrupted(StoredId storedId)
778-
{
779-
await using var conn = await _connFunc();
780-
_interruptedSql ??= @$"
781-
SELECT Interrupted
782-
FROM {_tableName}
783-
WHERE Id = @Id;";
784775

785-
await using var command = new SqlCommand(_interruptedSql, conn);
786-
command.Parameters.AddWithValue("@Id", storedId.AsGuid);
787-
788-
var interrupted = await command.ExecuteScalarAsync();
789-
return (bool?) interrupted;
790-
}
791776

792777
private string? _getFunctionStatusSql;
793778
public async Task<Status?> GetFunctionStatus(StoredId storedId)

0 commit comments

Comments
 (0)