Skip to content

Commit fc328b4

Browse files
committed
SE-0428: adjust macro name to SE accepted name: @resolvable
1 parent aa266d2 commit fc328b4

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

proposals/0428-resolve-distributed-actor-protocols.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ This is common and acceptable in a **peer-to-peer system**, where all nodes of a
4848
The goal of this proposal is to allow the following module approach to sharing distributed actor APIs:
4949
- **API** module: allow sharing a `DistributedActor` constrained protocol, which only declares the API surface the server is going to expose
5050
- **Server** module: which depends on API module, and implements the API description using a concrete distributed actor
51-
- **Client** module: which depends on API module, and `$Greeter` type (synthesized by the `@DistributedProtocol` macro) to resolve a remote actor reference it can then invoke distributed methods on
51+
- **Client** module: which depends on API module, and `$Greeter` type (synthesized by the `@Resolvable` macro) to resolve a remote actor reference it can then invoke distributed methods on
5252

5353
```swift
5454
┌────────────────────────────────────────┐
5555
API Module
5656
│========================================│
57-
@DistributedProtocol
57+
@Resolvable
5858
protocol Greeter: DistributedActor {
5959
┌───────┤ distributed func greet(name: String) ├───────┐
6060
}
@@ -75,22 +75,22 @@ The goal of this proposal is to allow the following module approach to sharing d
7575
In this scenario the client module has no knowledge of the concrete distributed actor type or implementation.
7676

7777
In order to achieve this, this proposal improves upon _three_ aspects of distributed actors:
78-
- introduce the `@DistributedProtocol` macro that can be attached to distributed actor protocols, and enable the use of `resolve(id:using:)` with such types,
78+
- introduce the `@Resolvable` macro that can be attached to distributed actor protocols, and enable the use of `resolve(id:using:)` with such types,
7979
- allow distributed actors to be generic over their `ActorSystem`
8080
- extend the distributed metadata section such that a distributed method which is witness to a distributed requirement, is also recorded using the protocol method's `RemoteCallTarget.identifier` and not only the concrete method's
8181

8282
## Proposed solution
8383

84-
### The `@DistributedProtocol` macro
84+
### The `@Resolvable` macro
8585

86-
At the core of this proposal is the `@DistributedProtocol` macro. It is an attached declaration macro, which introduces a number of declarations which allow the protocol, or rather, a "stub" type for the protocol, to be used on a client without knowledge about the server implementation's concrete distributed actor type.
86+
At the core of this proposal is the `@Resolvable` macro. It is an attached declaration macro, which introduces a number of declarations which allow the protocol, or rather, a "stub" type for the protocol, to be used on a client without knowledge about the server implementation's concrete distributed actor type.
8787

8888
The macro must be attached to the a `protocol` declaration that is a `DistributedActor` constrained protocol, like this:
8989

9090
```swift
9191
import Distributed
9292

93-
@DistributedProtocol
93+
@Resolvable
9494
protocol Greeter where ActorSystem: DistributedActorSystem<any Codable> {
9595
distributed func greet(name: String) -> String
9696
}
@@ -102,7 +102,7 @@ Checking of distributed functions works as before, and the compiler will check t
102102

103103
It is possible to for a distributed actor protocol to contain non-distributed requirements. However in practice, it will be impossible to ever invoke such methods on a remote distributed actor reference. It is possible to call such methods if one were to obtain a local distributed actor reference implementing such protocol, and use the existing `whenLocal(operation:)` method on it.
104104

105-
The `@DistributedProtocol` macro generates a number of internal declarations necessary for the distributed machinery to work, however the only type users should care about is always a `$`-prefixed concrete distributed actor declaration, that is the "stub" type. This stub type can be used to resolve a remote actor using this protocol stub:
105+
The `@Resolvable` macro generates a number of internal declarations necessary for the distributed machinery to work, however the only type users should care about is always a `$`-prefixed concrete distributed actor declaration, that is the "stub" type. This stub type can be used to resolve a remote actor using this protocol stub:
106106

107107
E.g. if we knew a remote has a `Greeter` instance for a specific ID we have discovered using some external mechanism, this is how we'd resolve it:
108108

@@ -200,17 +200,17 @@ The serialization requirement must be a `protocol` type; This was previously enf
200200

201201
## Detailed design
202202

203-
The `@DistributedProtocol` macro generates a concrete `distributed actor` declaration as well as an extension which implements the protocol's method requirements with "stub" implementations.
203+
The `@Resolvable` macro generates a concrete `distributed actor` declaration as well as an extension which implements the protocol's method requirements with "stub" implementations.
204204

205-
> **NOTE:** The exact details of the macro synthesized code are not guaranteed to remain the same, and may change without notice. The existence of the $-prefixed generated type is guaranteed however, as it is the public API how developers resolve and obtain remote references, I.e. for a `protocol Greeter` annotated with the `@DistributedProtocol` macro, developers may rely on the existence of the `distributed actor $Greeter` with the same access level as the protocol.
205+
> **NOTE:** The exact details of the macro synthesized code are not guaranteed to remain the same, and may change without notice. The existence of the $-prefixed generated type is guaranteed however, as it is the public API how developers resolve and obtain remote references, I.e. for a `protocol Greeter` annotated with the `@Resolvable` macro, developers may rely on the existence of the `distributed actor $Greeter` with the same access level as the protocol.
206206
207207
This proposal also introduces an empty `DistributedActorStub` protocol:
208208

209209
```swift
210210
public protocol DistributedActorStub where Self: DistributedActor {}
211211
```
212212

213-
The `@DistributedProtocol` macro synthesizes a concrete distributed actor which accepts a generic `ActorSystem`. The generated actor declaration matches access level with the original declaration, and implements the protocol as well as the `DistributedActorStub` protocol:
213+
The `@Resolvable` macro synthesizes a concrete distributed actor which accepts a generic `ActorSystem`. The generated actor declaration matches access level with the original declaration, and implements the protocol as well as the `DistributedActorStub` protocol:
214214

215215
```swift
216216
protocol Greeter: DistributedActor where ActorSystem: DistributedActorSystem<any Codable> {
@@ -230,9 +230,9 @@ extension Greeter where Self: DistributedActorStub {
230230

231231
Default implementations for all the protocol's requirements (including non-distributed requirements) are provided by extensions utilizing the `DistributedActorStub` protocol.
232232

233-
It is possible for a protocol type to inherit other protocols, in that case the parent protocol must either have default implementations for all its requirements, or it must also apply the `@DistributedProtocol` protocol which generates such default implementations.
233+
It is possible for a protocol type to inherit other protocols, in that case the parent protocol must either have default implementations for all its requirements, or it must also apply the `@Resolvable` protocol which generates such default implementations.
234234

235-
The default method "stub" implementations provided by the `@DistributedProtocol` simply fatal error if they were to ever be invoked. In practice, invoking those methods is not possible, because resolving a stub will always return a remote reference, and therefore calls on these methods are redirected to `DistributedActorSystem`'s `remoteCall` rather than invoking the "local" methods.
235+
The default method "stub" implementations provided by the `@Resolvable` simply fatal error if they were to ever be invoked. In practice, invoking those methods is not possible, because resolving a stub will always return a remote reference, and therefore calls on these methods are redirected to `DistributedActorSystem`'s `remoteCall` rather than invoking the "local" methods.
236236

237237
It is recommended to use `some Greeter` or `any Greeter` rather than `$Greeter` when passing around resolved instances of a distributed actor protocol. This way none of your code is tied to the fact of using a specific type of proxy, but rather, can accept any greeter, be it local or resolved through a proxy reference. This can come in handy when refactoring a codebase, and merging modules in such way where the greeter may actually be a local instance in some situations.
238238

@@ -275,7 +275,7 @@ A shared module introducing the `Capybara` protocol:
275275

276276
```swift
277277
// Module "Shared"
278-
@DistributedProtocol
278+
@Resolvable
279279
public protocol Capybara where ActorSystem: DistributedActorSystem<any Codable> {
280280
distributed var name: String { get }
281281
distributed func eat()
@@ -378,7 +378,7 @@ We find that the needs of distributed protocol evolution overlap in some parts w
378378
This could be handled with declaration macros, introducing a peer method with the expected new API:
379379

380380
```swift
381-
@DistributedProtocol(deprecatedName: "Greeter")
381+
@Resolvable(deprecatedName: "Greeter")
382382
protocol DeprecatedGreeter: DistributedActor {
383383
@Distributed.Deprecated(newVersion: greet(name:), defaults: [name: nil])
384384
distributed func greet() -> String

0 commit comments

Comments
 (0)