Skip to content

Commit 290506d

Browse files
committed
Add LocalTestingActorAddress
1 parent 97da205 commit 290506d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,27 @@
1212

1313
import Swift
1414

15+
public struct LocalTestingActorAddress: Hashable, Sendable, Codable {
16+
public let address: String
17+
18+
public init(parse address: String) {
19+
self.address = address
20+
}
21+
22+
public init(from decoder: Decoder) throws {
23+
let container = try decoder.singleValueContainer()
24+
self.address = try container.decode(String.self)
25+
}
26+
27+
public func encode(to encoder: Encoder) throws {
28+
var container = encoder.singleValueContainer()
29+
try container.encode(self.address)
30+
}
31+
}
32+
1533
// TODO(distributed): not thread safe...
1634
public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @unchecked Sendable {
17-
public typealias ActorID = ActorAddress
35+
public typealias ActorID = LocalTestingActorAddress
1836
public typealias InvocationEncoder = LocalTestingInvocationEncoder
1937
public typealias InvocationDecoder = LocalTestingInvocationDecoder
2038
public typealias SerializationRequirement = Codable
@@ -98,9 +116,9 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
98116

99117
init() {}
100118

101-
mutating func next() -> ActorAddress {
119+
mutating func next() -> LocalTestingActorAddress {
102120
self.counter += 1
103-
return ActorAddress(parse: "\(self.counter)")
121+
return LocalTestingActorAddress(parse: "\(self.counter)")
104122
}
105123
}
106124
}

0 commit comments

Comments
 (0)