Skip to content

Commit cdb99ea

Browse files
committed
experimenting
1 parent bed7d38 commit cdb99ea

File tree

3 files changed

+64
-57
lines changed

3 files changed

+64
-57
lines changed

Package.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,9 @@ var globalConcurrencyFlags: [String] = [
1313
"-Xfrontend", "-disable-availability-checking", // TODO(distributed): remove this flag
1414
]
1515

16-
// TODO: currently disabled warnings as errors because of Sendable check noise and work in progress on different toolchains
17-
// if ProcessInfo.processInfo.environment["SACT_WARNINGS_AS_ERRORS"] != nil {
18-
// print("SACT_WARNINGS_AS_ERRORS enabled, passing `-warnings-as-errors`")
19-
// var allUnsafeFlags = globalConcurrencyFlags
20-
// allUnsafeFlags.append(contentsOf: [
21-
// "-warnings-as-errors",
22-
// ])
23-
// globalSwiftSettings = [
24-
// SwiftSetting.unsafeFlags(allUnsafeFlags),
25-
// ]
26-
// } else {
2716
globalSwiftSettings = [
2817
SwiftSetting.unsafeFlags(globalConcurrencyFlags),
2918
]
30-
// }
3119

3220
var targets: [PackageDescription.Target] = [
3321
// ==== ------------------------------------------------------------------------------------------------------------
@@ -202,6 +190,7 @@ var dependencies: [Package.Dependency] = [
202190
.package(url: "https://github.com/apple/swift-cluster-membership.git", from: "0.3.0"),
203191

204192
.package(url: "https://github.com/apple/swift-nio.git", from: "2.12.0"),
193+
// .package(name: "swift-nio", path: "/Users/ktoso/code/swift-distributed-actors/Packages/swift-nio"),
205194
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.2.0"),
206195
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.16.1"),
207196

Sources/DistributedActors/ActorAddress.swift

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -789,64 +789,82 @@ extension UniqueNodeID {
789789

790790
extension ActorAddress: Codable {
791791
public func encode(to encoder: Encoder) throws {
792-
let tagSettings = encoder.actorSerializationContext?.system.settings.tags
793-
let encodeCustomTags: (ActorAddress, inout KeyedEncodingContainer<ActorCoding.TagKeys>) throws -> Void =
794-
tagSettings?.encodeCustomTags ?? ({ _, _ in () })
795-
796792
var container = encoder.container(keyedBy: ActorCoding.CodingKeys.self)
797793
try container.encode(self.uniqueNode, forKey: ActorCoding.CodingKeys.node)
798-
try container.encode(self.path, forKey: ActorCoding.CodingKeys.path) // TODO: remove as we remove the tree
794+
try container.encode(self.path, forKey: ActorCoding.CodingKeys.path)
799795
try container.encode(self.incarnation, forKey: ActorCoding.CodingKeys.incarnation)
800-
801-
if !self.tags.isEmpty {
802-
var tagsContainer = container.nestedContainer(keyedBy: ActorCoding.TagKeys.self, forKey: ActorCoding.CodingKeys.tags)
803-
804-
if (tagSettings == nil || tagSettings!.propagateTags.contains(AnyActorTagKey(ActorTags.path))),
805-
let value = self.tags[ActorTags.path]
806-
{
807-
try tagsContainer.encode(value, forKey: ActorCoding.TagKeys.path)
808-
}
809-
if (tagSettings == nil || tagSettings!.propagateTags.contains(AnyActorTagKey(ActorTags.type))),
810-
let value = self.tags[ActorTags.type]
811-
{
812-
try tagsContainer.encode(value, forKey: ActorCoding.TagKeys.type)
813-
}
814-
815-
try encodeCustomTags(self, &tagsContainer)
816-
}
817796
}
818797

819798
public init(from decoder: Decoder) throws {
820799
let container = try decoder.container(keyedBy: ActorCoding.CodingKeys.self)
821800
let node = try container.decode(UniqueNode.self, forKey: ActorCoding.CodingKeys.node)
822-
let path = try container.decodeIfPresent(ActorPath.self, forKey: ActorCoding.CodingKeys.path)
801+
let path = try container.decode(ActorPath.self, forKey: ActorCoding.CodingKeys.path)
823802
let incarnation = try container.decode(UInt32.self, forKey: ActorCoding.CodingKeys.incarnation)
824803

825804
self.init(remote: node, path: path, incarnation: ActorIncarnation(incarnation))
826-
827-
// Decode any tags:
828-
if let tagsContainer = try? container.nestedContainer(keyedBy: ActorCoding.TagKeys.self, forKey: ActorCoding.CodingKeys.tags) {
829-
// tags container found, try to decode all known tags:
830-
if let path = try tagsContainer.decodeIfPresent(ActorPath.self, forKey: .path) {
831-
self.tags[ActorTags.path] = path
832-
}
833-
834-
if let context = decoder.actorSerializationContext {
835-
let decodeCustomTags = context.system.settings.tags.decodeCustomTags
836-
837-
for tag in try decodeCustomTags(tagsContainer) {
838-
func store<K: ActorTagKey>(_: K.Type) {
839-
if let value = tag.value as? K.Value {
840-
self.tags[K.self] = value
841-
}
842-
}
843-
_openExistential(tag.keyType as any ActorTagKey.Type, do: store) // the `as` here is required, because: inferred result type 'any ActorTagKey.Type' requires explicit coercion due to loss of generic requirements
844-
}
845-
}
846-
}
847805
}
848806
}
849807

808+
// extension ActorAddress: Codable {
809+
// public func encode(to encoder: Encoder) throws {
810+
// let tagSettings = encoder.actorSerializationContext?.system.settings.tags
811+
// let encodeCustomTags: (ActorAddress, inout KeyedEncodingContainer<ActorCoding.TagKeys>) throws -> Void =
812+
// tagSettings?.encodeCustomTags ?? ({ _, _ in () })
813+
//
814+
// var container = encoder.container(keyedBy: ActorCoding.CodingKeys.self)
815+
// try container.encode(self.uniqueNode, forKey: ActorCoding.CodingKeys.node)
816+
// try container.encode(self.path, forKey: ActorCoding.CodingKeys.path) // TODO: remove as we remove the tree
817+
// try container.encode(self.incarnation, forKey: ActorCoding.CodingKeys.incarnation)
818+
//
819+
// if !self.tags.isEmpty {
820+
// var tagsContainer = container.nestedContainer(keyedBy: ActorCoding.TagKeys.self, forKey: ActorCoding.CodingKeys.tags)
821+
//
822+
// if (tagSettings == nil || tagSettings!.propagateTags.contains(AnyActorTagKey(ActorTags.path))),
823+
// let value = self.tags[ActorTags.path]
824+
// {
825+
// try tagsContainer.encode(value, forKey: ActorCoding.TagKeys.path)
826+
// }
827+
// if (tagSettings == nil || tagSettings!.propagateTags.contains(AnyActorTagKey(ActorTags.type))),
828+
// let value = self.tags[ActorTags.type]
829+
// {
830+
// try tagsContainer.encode(value, forKey: ActorCoding.TagKeys.type)
831+
// }
832+
//
833+
// try encodeCustomTags(self, &tagsContainer)
834+
// }
835+
// }
836+
//
837+
// public init(from decoder: Decoder) throws {
838+
// let container = try decoder.container(keyedBy: ActorCoding.CodingKeys.self)
839+
// let node = try container.decode(UniqueNode.self, forKey: ActorCoding.CodingKeys.node)
840+
// let path = try container.decodeIfPresent(ActorPath.self, forKey: ActorCoding.CodingKeys.path)
841+
// let incarnation = try container.decode(UInt32.self, forKey: ActorCoding.CodingKeys.incarnation)
842+
//
843+
// self.init(remote: node, path: path, incarnation: ActorIncarnation(incarnation))
844+
//
845+
// // Decode any tags:
846+
// if let tagsContainer = try? container.nestedContainer(keyedBy: ActorCoding.TagKeys.self, forKey: ActorCoding.CodingKeys.tags) {
847+
// // tags container found, try to decode all known tags:
848+
// if let path = try tagsContainer.decodeIfPresent(ActorPath.self, forKey: .path) {
849+
// self.tags[ActorTags.path] = path
850+
// }
851+
//
852+
// if let context = decoder.actorSerializationContext {
853+
// let decodeCustomTags = context.system.settings.tags.decodeCustomTags
854+
//
855+
// for tag in try decodeCustomTags(tagsContainer) {
856+
// func store<K: ActorTagKey>(_: K.Type) {
857+
// if let value = tag.value as? K.Value {
858+
// self.tags[K.self] = value
859+
// }
860+
// }
861+
// _openExistential(tag.keyType as any ActorTagKey.Type, do: store) // the `as` here is required, because: inferred result type 'any ActorTagKey.Type' requires explicit coercion due to loss of generic requirements
862+
// }
863+
// }
864+
// }
865+
// }
866+
// }
867+
850868
// ==== ----------------------------------------------------------------------------------------------------------------
851869
// MARK: Path errors
852870

Tests/DistributedActorsTests/ActorAskTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ final class ActorAskTests: ActorSystemXCTestCase {
204204

205205
func test_ask_withTerminatedSystem_shouldNotCauseCrash() async throws {
206206
throw XCTSkip("TODO: not sure why this is hanging but relates to the NIO Futures issue I'm sure") // FIXME: unlock this test and fix NIO future handling
207-
207+
208208
let system = await ClusterSystem("AskCrashSystem")
209209

210210
let ref = try system._spawn(

0 commit comments

Comments
 (0)