Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let targets: [PackageDescription.Target] = [
"SwiftProtobuf",

"Logging", "Metrics",
"Backtrace",

"DistributedActorsConcurrencyHelpers",
"CDistributedActorsMailbox",
Expand Down Expand Up @@ -152,8 +153,10 @@ let dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-metrics.git", from: "1.0.0"),

.package(url: "https://github.com/ianpartridge/swift-backtrace.git", .branch("master")),

// ~~~ only for samples ~~~
.package(url: "https://github.com/MrLotU/SwiftPrometheus", .branch("master")),
.package(url: "https://github.com/MrLotU/SwiftPrometheus", .branch("master"))
]

let package = Package(
Expand Down
6 changes: 6 additions & 0 deletions Sources/DistributedActors/ActorSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

import Backtrace
import CDistributedActorsMailbox
import Dispatch
import DistributedActorsConcurrencyHelpers
Expand Down Expand Up @@ -124,6 +125,11 @@ public final class ActorSystem {
var settings = settings
self.name = settings.cluster.node.systemName

// rely on swift-backtrace for pretty backtraces on crashes
if settings.installSwiftBacktrace {
Backtrace.install()
}

// TODO: we should not rely on NIO for futures
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: settings.threadPoolSize)
settings.cluster.eventLoopGroup = eventLoopGroup
Expand Down
3 changes: 3 additions & 0 deletions Sources/DistributedActors/ActorSystemSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public struct ActorSystemSettings {
}
}

/// Installs a global backtrace (on fault) pretty-print facility upon actor system start.
public var installSwiftBacktrace: Bool = true

// FIXME: should have more proper config section
public var threadPoolSize: Int = ProcessInfo.processInfo.activeProcessorCount
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/DistributedActors/Cluster/ClusterShellState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ extension ClusterShellState {

switch state {
case .initiated(let initiated):
assert(initiated.channel != nil, "Channel should always be present after the initial initialization.")
assert(initiated.channel != nil, "Channel should always be present after the initial initialization, state was: \(state)")
_ = initiated.channel?.close()
case .wasOfferedHandshake:
fatalError("abortOutgoingHandshake was called in a context where the handshake was not an outgoing one! Was: \(state)")
Expand Down