Skip to content

Commit

Permalink
Rename the deprecated ActorAddress naming to DA-style ActorID (#946)
Browse files Browse the repository at this point in the history
* reviving them docs

* hide StashBuffer - not needed in DA world

* hide SerializationPoolSettings, will be exposed via tagging in future

* some more docs; hide NodeDeathWatcherError

* listings topics

* hide: traversal apis, resolve actor refs

* Rename ActorAddress -> ActorID

* fix snippet only built on CI
  • Loading branch information
ktoso authored Jun 6, 2022
1 parent f5441b0 commit 9bd94ba
Show file tree
Hide file tree
Showing 133 changed files with 3,599 additions and 2,762 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.7.0"),

// ~~~ backtraces ~~~
// TODO: optimally, library should not pull swift-backtrace
.package(url: "https://github.com/swift-server/swift-backtrace.git", from: "1.1.1"),

// ~~~ Swift Collections ~~~
Expand Down
7 changes: 4 additions & 3 deletions Protos/ActorAddress.proto → Protos/ActorID.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift Distributed Actors open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Distributed Actors project authors
// Copyright (c) 2018-2022 Apple Inc. and the Swift Distributed Actors project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -17,10 +17,11 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

message ActorAddress {
UniqueNode node = 1; // TODO oneof { senderNode | recipientNode | node }
message ActorID {
UniqueNode node = 1;
ActorPath path = 2;
uint32 incarnation = 3;
// TODO: encode tags
}

message ActorPath {
Expand Down
4 changes: 2 additions & 2 deletions Protos/Clocks/VersionVector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";
import "Serialization/Serialization.proto";

// ==== Replica ID -----------------------------------------------------------------------------------------------------
Expand All @@ -30,7 +30,7 @@ message ActorIdentity {

message VersionReplicaID {
oneof value {
ActorAddress actorAddress = 1;
ActorID actorID = 1;
UniqueNode uniqueNode = 2;
uint64 uniqueNodeID = 3;
}
Expand Down
2 changes: 1 addition & 1 deletion Protos/Cluster/Cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";
import "Cluster/ClusterEvents.proto";

message ClusterShellMessage {
Expand Down
2 changes: 1 addition & 1 deletion Protos/Cluster/ClusterEvents.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";
import "Cluster/Membership.proto";

message ClusterEvent {
Expand Down
4 changes: 2 additions & 2 deletions Protos/Cluster/Membership.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";
import "Clocks/VersionVector.proto";

message ClusterMembership {
Expand Down Expand Up @@ -68,4 +68,4 @@ message ClusterMembershipSeenTable {
message ClusterMembershipSeenTableRow {
uint64 uniqueNodeID = 1;
VersionVector version = 2;
}
}
14 changes: 7 additions & 7 deletions Protos/Cluster/SWIM/SWIM.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";

message SWIMRemoteMessage {
oneof message {
Expand All @@ -29,27 +29,27 @@ message SWIMRemoteMessage {
}

message SWIMPing {
ActorAddress origin = 1;
ActorID origin = 1;
SWIMGossipPayload payload = 2;
uint32 sequenceNumber = 3;
}

message SWIMPingRequest {
ActorAddress target = 1;
ActorAddress origin = 2;
ActorID target = 1;
ActorID origin = 2;
SWIMGossipPayload payload = 3;
uint32 sequenceNumber = 4;
}

message SWIMPingResponse {
message Ack {
ActorAddress target = 1;
ActorID target = 1;
uint64 incarnation = 2;
SWIMGossipPayload payload = 3;
uint32 sequenceNumber = 4;
}
message Nack {
ActorAddress target = 1;
ActorID target = 1;
uint32 sequenceNumber = 2;
}
oneof pingResponse {
Expand All @@ -73,7 +73,7 @@ message SWIMStatus {
}

message SWIMMember {
ActorAddress address = 1;
ActorID id = 1;
SWIMStatus status = 2;
uint64 protocolPeriod = 3;
}
Expand Down
14 changes: 7 additions & 7 deletions Protos/SystemMessages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";

// ==== System Message -------------------------------------------------------------------------------------------------

Expand All @@ -31,19 +31,19 @@ message SystemMessage {
}

message SystemMessage_Watch {
ActorAddress watchee = 1;
ActorAddress watcher = 2;
ActorID watchee = 1;
ActorID watcher = 2;
}

message SystemMessage_Unwatch {
ActorAddress watchee = 1;
ActorAddress watcher = 2;
ActorID watchee = 1;
ActorID watcher = 2;
}

message SystemMessage_Terminated {
ActorAddress ref = 1;
ActorID ref = 1;
bool existenceConfirmed = 2;
bool addressTerminated = 3;
bool idTerminated = 3;
}

// ==== Redelivery -----------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Protos/WireProtocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto3";
option optimize_for = SPEED;
option swift_prefix = "_Proto";

import "ActorAddress.proto";
import "ActorID.proto";
import "Serialization/Serialization.proto";

// ==== Handshake ------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -57,7 +57,7 @@ message HandshakeReject {
// ==== Envelope -------------------------------------------------------------------------------------------------------

message Envelope {
ActorAddress recipient = 1;
ActorID recipient = 1;

Manifest manifest = 2;
bytes payload = 3;
Expand Down
2 changes: 1 addition & 1 deletion Sources/ActorSingletonPlugin/ActorSingleton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal struct BoxedActorSingleton: AnyActorSingleton {
extension ActorSingleton: AnyActorSingleton {
func stop(_ system: ClusterSystem) {
// Hand over the singleton gracefully
let resolveContext = ResolveContext<ActorSingletonManager<Message>.Directive>(address: ._singletonManager(name: self.settings.name, on: system.cluster.uniqueNode), system: system)
let resolveContext = ResolveContext<ActorSingletonManager<Message>.Directive>(id: ._singletonManager(name: self.settings.name, on: system.cluster.uniqueNode), system: system)
let managerRef = system._resolve(context: resolveContext)
// If the manager is not running this will end up in dead-letters but that's fine
managerRef.tell(.stop)
Expand Down
6 changes: 3 additions & 3 deletions Sources/ActorSingletonPlugin/ActorSingletonManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ extension ActorSingletonManager {
// ==== ----------------------------------------------------------------------------------------------------------------
// MARK: ActorSingletonManager path / address

extension ActorAddress {
static func _singletonManager(name: String, on node: UniqueNode) -> ActorAddress {
ActorAddress(local: node, path: ._singletonManager(name: name), incarnation: .wellKnown)
extension ActorID {
static func _singletonManager(name: String, on node: UniqueNode) -> ActorID {
ActorID(local: node, path: ._singletonManager(name: name), incarnation: .wellKnown)
}
}

Expand Down
14 changes: 7 additions & 7 deletions Sources/ActorSingletonPlugin/ActorSingletonProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ internal class ActorSingletonProxy<Message: ActorMessage> {
// to have proxies ask the `targetNode` proxy to "send me the ref once you have taken over"
// and before then the proxies can either set `ref` to `nil` (to stash messages) or to `targetNode`
// proxy as we do today. The challenge lies in serialization, as ActorSingletonProxy and ActorSingletonManager are generic.
let resolveContext = ResolveContext<Message>(address: ._singletonProxy(name: self.settings.name, remote: node), system: context.system)
let resolveContext = ResolveContext<Message>(id: ._singletonProxy(name: self.settings.name, remote: node), system: context.system)
let ref = context.system._resolve(context: resolveContext)
self.updateRef(context, ref)
case .none:
Expand All @@ -188,7 +188,7 @@ internal class ActorSingletonProxy<Message: ActorMessage> {
private func forwardOrStash(_ context: _ActorContext<Message>, message: Message) throws {
// Forward the message if `singleton` is not `nil`, else stash it.
if let singleton = self.ref {
context.log.trace("Forwarding message \(message), to: \(singleton.address)", metadata: self.metadata(context))
context.log.trace("Forwarding message \(message), to: \(singleton.id)", metadata: self.metadata(context))
singleton.tell(message)
} else {
do {
Expand All @@ -201,7 +201,7 @@ internal class ActorSingletonProxy<Message: ActorMessage> {
context.log.warning("Buffer is full. Messages might start getting disposed.", metadata: self.metadata(context))
// Move the oldest message to dead letters to make room
if let oldestMessage = self.buffer.take() {
context.system.deadLetters.tell(DeadLetter(oldestMessage, recipient: context.address))
context.system.deadLetters.tell(DeadLetter(oldestMessage, recipient: context.id))
}
default:
context.log.warning("Unable to stash message, error: \(error)", metadata: self.metadata(context))
Expand All @@ -224,10 +224,10 @@ extension ActorSingletonProxy {

metadata["targetNode"] = "\(optional: self.targetNode?.debugDescription)"
if let ref = self.ref {
metadata["ref"] = "\(ref.address)"
metadata["ref"] = "\(ref.id)"
}
if let managerRef = self.managerRef {
metadata["managerRef"] = "\(managerRef.address)"
metadata["managerRef"] = "\(managerRef.id)"
}

return metadata
Expand All @@ -237,8 +237,8 @@ extension ActorSingletonProxy {
// ==== ----------------------------------------------------------------------------------------------------------------
// MARK: Singleton path / address

extension ActorAddress {
static func _singletonProxy(name: String, remote node: UniqueNode) -> ActorAddress {
extension ActorID {
static func _singletonProxy(name: String, remote node: UniqueNode) -> ActorID {
.init(remote: node, path: ._singletonProxy(name: name), incarnation: .wellKnown)
}
}
Expand Down
Loading

0 comments on commit 9bd94ba

Please sign in to comment.