Skip to content

Commit 41cafad

Browse files
authored
Rename AskError to RemoteCallError (#928)
Resolves #905
1 parent ee51bce commit 41cafad

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

Sources/DistributedActors/ActorRef+Ask.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ extension _ActorRef: ReceivesQuestions {
7171
_ makeQuestion: @escaping (_ActorRef<Answer>) -> Question
7272
) -> AskResponse<Answer> {
7373
guard let system = self._system else {
74-
return .completed(.failure(AskError.systemAlreadyShutDown))
74+
return .completed(.failure(RemoteCallError.clusterAlreadyShutDown))
7575
}
7676

7777
if system.isShuttingDown {
78-
return .completed(.failure(AskError.systemAlreadyShutDown))
78+
return .completed(.failure(RemoteCallError.clusterAlreadyShutDown))
7979
}
8080

8181
do {
@@ -147,11 +147,6 @@ enum AskResponse<Value> {
147147
case nioFuture(EventLoopFuture<Value>)
148148
}
149149

150-
enum AskError: DistributedActorSystemError, Error {
151-
case timedOut(TimeoutError)
152-
case systemAlreadyShutDown
153-
}
154-
155150
extension AskResponse {
156151
/// Blocks and waits until there is a response or fails with an error.
157152
@available(*, deprecated, message: "Blocking API will be removed in favor of async await")
@@ -203,7 +198,7 @@ extension AskResponse: _AsyncResult {
203198
let eventLoop = nioFuture.eventLoop
204199
let promise: EventLoopPromise<Value> = eventLoop.makePromise()
205200
let timeoutTask = eventLoop.scheduleTask(in: timeout.toNIO) {
206-
promise.fail(AskError.timedOut(TimeoutError(message: "\(type(of: self)) timed out after \(timeout.prettyDescription)", timeout: timeout)))
201+
promise.fail(RemoteCallError.timedOut(TimeoutError(message: "\(type(of: self)) timed out after \(timeout.prettyDescription)", timeout: timeout)))
207202
}
208203
nioFuture.whenFailure {
209204
timeoutTask.cancel()
@@ -283,7 +278,7 @@ internal enum AskActor {
283278
Ask was initiated from function [\(function)] in [\(file):\(line)] and \
284279
expected response of type [\(String(reflecting: ResponseType.self))].
285280
"""
286-
completable.fail(AskError.timedOut(TimeoutError(message: errorMessage, timeout: timeout)))
281+
completable.fail(RemoteCallError.timedOut(TimeoutError(message: errorMessage, timeout: timeout)))
287282

288283
// FIXME: Hack to stop from subReceive. Should we allow this somehow?
289284
// Maybe add a SubReceiveContext or similar?

Sources/DistributedActors/Cluster/Reception/OperationLogDistributedReceptionist.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ extension OpLogDistributedReceptionist {
636636
try await peerReceptionistRef.ackOps(until: latestAppliedSeqNrFromPeer, by: self)
637637
} catch {
638638
switch error {
639-
case AskError.systemAlreadyShutDown:
639+
case RemoteCallError.clusterAlreadyShutDown:
640640
// ignore silently; this often happens during tests when we terminate systems while interacting with them
641641
()
642642
default:

Sources/DistributedActors/ClusterSystem.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ extension ClusterSystem {
951951
Err: Error
952952
{
953953
guard let shell = self._cluster else {
954-
throw AskError.systemAlreadyShutDown
954+
throw RemoteCallError.clusterAlreadyShutDown
955955
}
956956

957957
let recipient = _ActorRef<InvocationMessage>(.remote(.init(shell: shell, address: actor.id._asRemote, system: self)))
@@ -1065,8 +1065,9 @@ internal struct LazyStart<Message: ActorMessage> {
10651065
}
10661066
}
10671067

1068-
enum RemoteCallError: Error {
1068+
enum RemoteCallError: DistributedActorSystemError, Error {
10691069
case clusterAlreadyShutDown
1070+
case timedOut(TimeoutError)
10701071
}
10711072

10721073
/// Allows for configuring of remote calls by setting task-local values around a remote call being made.

Tests/DistributedActorsTests/ActorAskTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ final class ActorAskTests: ActorSystemXCTestCase {
6666
_ = try response.wait()
6767
}
6868

69-
guard case AskError.timedOut = error else {
70-
throw testKit.fail("Expected AskError.timedOut, got \(error)")
69+
guard case RemoteCallError.timedOut = error else {
70+
throw testKit.fail("Expected RemoteCallError.timedOut, got \(error)")
7171
}
7272
}
7373

@@ -197,8 +197,8 @@ final class ActorAskTests: ActorSystemXCTestCase {
197197
try result.wait()
198198
}
199199

200-
guard case AskError.timedOut = error else {
201-
throw testKit.fail("Expected AskError.timedOut, got \(error)")
200+
guard case RemoteCallError.timedOut = error else {
201+
throw testKit.fail("Expected RemoteCallError.timedOut, got \(error)")
202202
}
203203
}
204204

Tests/DistributedActorsTests/ClusterSystemTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ final class ClusterSystemTests: ActorSystemXCTestCase {
165165
}
166166
}
167167

168-
guard case AskError.timedOut(let timeoutError) = error else {
169-
throw testKit.fail("Expected AskError.timedOut, got \(error)")
168+
guard case RemoteCallError.timedOut(let timeoutError) = error else {
169+
throw testKit.fail("Expected RemoteCallError.timedOut, got \(error)")
170170
}
171171
guard timeoutError.timeout == .seconds(1) else {
172172
throw testKit.fail("Expected timeout to be 1 second but was \(timeoutError.timeout)")

0 commit comments

Comments
 (0)