Skip to content

Commit 968a64e

Browse files
ktosoyim-lee
andauthored
Apply suggestions from code review
Co-authored-by: Yim Lee <[email protected]>
1 parent 1f840d7 commit 968a64e

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import _Concurrency
2525
/// It is not possible to conform to this protocol manually by any other type
2626
/// than a `distributed actor`.
2727
///
28-
/// It is possible to require a type conform to the
28+
/// It is possible to require a type to conform to the
2929
/// ``DistributedActor`` protocol by refining it with another protocol,
3030
/// or by using a generic constraint.
3131
///
@@ -38,7 +38,7 @@ import _Concurrency
3838
/// - the ``SerializationRequirement`` that will be used at compile time to
3939
/// verify `distributed` target declarations are well formed,
4040
/// - if the distributed actor is `Codable`, based on the ``ID`` being Codable or not,
41-
/// - the type of the `ActorSystem` accepted in the synthesized default initializer.
41+
/// - the type of the ``ActorSystem`` accepted in the synthesized default initializer.
4242
///
4343
/// A distributed actor must declare what type of actor system it is ready to
4444
/// work with by fulfilling the ``ActorSystem`` type member requirement:
@@ -54,7 +54,7 @@ import _Concurrency
5454
/// ### The DefaultDistributedActorSystem type alias
5555
/// Since it is fairly common to only be using one specific type of actor system
5656
/// within a module or entire codebase, it is possible to declare the default type
57-
/// or actor system all distributed actors will be using in a module by declaring
57+
/// of actor system all distributed actors will be using in a module by declaring
5858
/// a `DefaultDistributedActorSystem` module wide typealias:
5959
///
6060
/// ```swift
@@ -66,8 +66,8 @@ import _Concurrency
6666
/// distributed actor Greeter {} // ActorSystem == AmazingActorSystem
6767
/// ```
6868
///
69-
/// This declaration makes all `distributed actor` declarations,
70-
/// which do not explicitly specify an ``ActorSystem`` typealias, to assume the
69+
/// This declaration makes all `distributed actor` declarations
70+
/// that do not explicitly specify an ``ActorSystem`` type alias to assume the
7171
/// `AmazingActorSystem` as their `ActorSystem`.
7272
///
7373
/// It is possible for a specific actor to override the system it is using,
@@ -95,8 +95,8 @@ import _Concurrency
9595
///
9696
/// The accepted actor system must be of the `Self.ActorSystem` type, which
9797
/// must conform to the ``DistributedActorSystem`` protocol. This is required
98-
/// because of how distributed actors are always managed by, a concrete
99-
/// distributed actor system, and cannot exist on their own without one.
98+
/// because distributed actors are always managed by a concrete
99+
/// distributed actor system and cannot exist on their own without one.
100100
///
101101
/// It is possible to explicitly declare an parameter-free initializer (`init()`),
102102
/// however the `actorSystem` property still must be assigned a concrete actor
@@ -105,7 +105,7 @@ import _Concurrency
105105
/// In general it is recommended to always have an `actorSystem` parameter as
106106
/// the last non-defaulted non-closure parameter in every distributed actors
107107
/// initializer parameter list. This way it is simple to swap in a "test actor
108-
// system" instance in unit tests, and avoid relying on global state which could
108+
/// system" instance in unit tests, and avoid relying on global state which could
109109
/// make testing more difficult.
110110
///
111111
/// ## Implicit properties
@@ -114,7 +114,7 @@ import _Concurrency
114114
///
115115
/// ### Property: Actor System
116116
/// The ``actorSystem`` property is an important part of every distributed actor's lifecycle management.
117-
/// Initialization as well as de-initialization both require interactions with the actor system,
117+
/// Both initialization as well as de-initialization require interactions with the actor system,
118118
/// and it is the actor system that delivers
119119
///
120120
///
@@ -131,23 +131,23 @@ import _Concurrency
131131
/// ```
132132
///
133133
/// ### Property: Distributed Actor Identity
134-
/// The ``id`` is assigned by the actor system during the distributed actor's
134+
/// ``id`` is assigned by the actor system during the distributed actor's
135135
/// initialization, and cannot be set or mutated by the actor itself.
136136
///
137-
/// The ``id`` is the effective identity of the actor, and is used in equality checks.
137+
/// ``id`` is the effective identity of the actor, and is used in equality checks.
138138
///
139139
/// ## Automatic Conformances
140140
///
141141
/// ### Hashable and Identifiable conformance
142-
/// Every distributed actor conforms to the Hashable and Identifiable protocols.
143-
/// Its identity is strictly driven by its `id`, and therefore hash and equality
144-
/// implementations directly delegate to the `id` property.
142+
/// Every distributed actor conforms to the `Hashable` and `Identifiable` protocols.
143+
/// Its identity is strictly driven by its ``id``, and therefore hash and equality
144+
/// implementations directly delegate to the ``id`` property.
145145
///
146146
/// Comparing a local distributed actor instance and a remote reference to it
147147
/// (both using the same ``id``) always returns true, as they both conceptually
148148
/// point at the same distributed actor.
149149
///
150-
/// It is not possible to implement those protocols relying on the actual actor's
150+
/// It is not possible to implement these protocols relying on the actual actor's
151151
/// state, because it may be remote and the state may not be available. In other
152152
/// words, since these protocols must be implemented using `nonisolated` functions,
153153
/// only `nonisolated` `id` and `actorSystem` properties are accessible for their
@@ -225,12 +225,12 @@ public protocol DistributedActor: AnyActor, Identifiable, Hashable
225225
@available(SwiftStdlib 5.7, *)
226226
extension DistributedActor {
227227

228-
/// A distributed actor's hash and equality is implemented by directly delegating to it's ``id``.
228+
/// A distributed actor's hash and equality is implemented by directly delegating to its ``id``.
229229
nonisolated public func hash(into hasher: inout Hasher) {
230230
self.id.hash(into: &hasher)
231231
}
232232

233-
/// A distributed actor's hash and equality is implemented by directly delegating to it's ``id``.
233+
/// A distributed actor's hash and equality is implemented by directly delegating to its ``id``.
234234
nonisolated public static func ==(lhs: Self, rhs: Self) -> Bool {
235235
lhs.id == rhs.id
236236
}
@@ -244,8 +244,8 @@ extension CodingUserInfoKey {
244244
/// to `init(from:)` a `DistributedActor`. The stored value under this key must
245245
/// conform to ``DistributedActorSystem``.
246246
///
247-
/// Missing to set this key will result in that initializer throwing, because
248-
/// an actor system is required
247+
/// Forgetting to set this key will result in that initializer throwing, because
248+
/// an actor system is required.
249249
@available(SwiftStdlib 5.7, *)
250250
public static let actorSystemKey = CodingUserInfoKey(rawValue: "$distributed_actor_system")!
251251
}
@@ -254,14 +254,14 @@ extension CodingUserInfoKey {
254254
extension DistributedActor /*: implicitly Decodable */ where Self.ID: Decodable {
255255

256256
/// Initializes an instance of this distributed actor by decoding its ``id``,
257-
/// and passing it to the ``DistributedActorSystem`` obtained from `decoder.userInfo[`actorSystemKey]`.
257+
/// and passing it to the ``DistributedActorSystem`` obtained from `decoder.userInfo[actorSystemKey]`.
258258
///
259259
/// ## Requires: The decoder must have the ``CodingUserInfoKey/actorSystemKey`` set to
260260
/// the ``ActorSystem`` that this actor expects, as it will be used to call ``DistributedActor/resolve(id:using:)``
261261
/// on, in order to obtain the instance this initializer should return.
262262
///
263263
/// - Parameter decoder: used to decode the ``ID`` of this distributed actor.
264-
/// - Throws: If the actor system value in `decoder.userInfo` is missing, or mis-typed;
264+
/// - Throws: If the actor system value in `decoder.userInfo` is missing or mis-typed;
265265
/// the `ID` fails to decode from the passed `decoder`;
266266
// or if the ``DistributedActor/resolve(id:using:)`` method invoked by this initializer throws.
267267
nonisolated public init(from decoder: Decoder) throws {
@@ -279,7 +279,7 @@ extension DistributedActor /*: implicitly Decodable */ where Self.ID: Decodable
279279
@available(SwiftStdlib 5.7, *)
280280
extension DistributedActor /*: implicitly Encodable */ where Self.ID: Encodable {
281281

282-
/// Encodes the ``actor.id`` as a single value into the passed `encoder`.
282+
/// Encodes the `actor.id` as a single value into the passed `encoder`.
283283
nonisolated public func encode(to encoder: Encoder) throws {
284284
var container = encoder.singleValueContainer()
285285
try container.encode(self.id)

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import _Concurrency
1515
/// A distributed actor system underpins and implements all functionality of distributed actors.
1616
///
1717
/// A ``DistributedActor`` is always initialized in association with some concrete actor system.
18-
/// And that actor system instance is then used to manage the identity of the actor, as well as
18+
/// That actor system instance is then used to manage the identity of the actor, as well as
1919
/// handle all remote interactions of the distributed actor.
2020
///
2121
/// ## Using a DistributedActorSystem library
@@ -28,7 +28,7 @@ import _Concurrency
2828
/// `typealias DefaultDistributedActorSystem`. Refer to the ``DistributedActor`` documentation to learn more
2929
/// about the tradeoffs of these approaches.
3030
///
31-
/// Once an actor has declared the system it is able to work with, such system instance must provided
31+
/// Once an actor has declared the system it is able to work with, an instance of the system must be provided
3232
/// at initialization time, in order for the system to be able to take over the actor's identity management.
3333
///
3434
/// For example, a simple distributed actor may look like this:
@@ -45,11 +45,11 @@ import _Concurrency
4545
/// This property is later used for identity management and other remote interactions of the actor.
4646
/// For more details refer to ``DistributedActor`` which explains more about declaring distributed actors.
4747
///
48-
/// For more details about how the specific actor system implementation deals with remote message transports,
48+
/// For more details about how the specific actor system implementation deals with remote message transports
4949
/// and serialization, please refer to the specific system's documentation.
5050
///
5151
/// > Note: For example, you may refer to the [Swift Distributed Actors cluster library](https://github.com/apple/swift-distributed-actors/) documentation,
52-
/// > which is one example of such feature complete distributed actor system implementation:
52+
/// > which is one example of such feature complete distributed actor system implementation.
5353
///
5454
/// ## Implementing a DistributedActorSystem
5555
///
@@ -99,9 +99,9 @@ import _Concurrency
9999
///
100100
/// > Tip: Take note that throwing or failable initializers complicate this somewhat. Thankfully, the compiler
101101
/// > will always emit the right code such that every ``assignID(_:)`` is balanced with a ``resignID(_:)`` call,
102-
/// > when the actor either failed to initialize, or deinitialized property.
102+
/// > when the actor either failed to initialize or deinitialize properly.
103103
/// >
104-
/// > It is also possible that a throwing initializer throws before assigning the actorSystem, and id properties.
104+
/// > It is also possible that a throwing initializer throws before assigning the `actorSystem` and `id` properties.
105105
/// > In such case, no `assignID` nor `resignID` calls are made. There is no risk of the compiler ever attempting
106106
/// > to call a `resignID(_:)` without first having assigned given ID.
107107
///
@@ -141,18 +141,18 @@ import _Concurrency
141141
/// > Note: Generally actor systems should retain actors _weakly_ in order to allow them be deinitialized when no longer in use.
142142
/// >
143143
/// > Sometimes though, it can be quite useful to have the system retain certain "well known" actors, for example when it is expected
144-
/// > that other nodes in the distributed system will need to interact with them, even if end-user code does no longer hold
144+
/// > that other nodes in the distributed system will need to interact with them, even if end-user code no longer holds
145145
/// > strong references to them. An example of such "retain while actor system is active" distributed actors would be any kind
146146
/// > of actor which implements discovery or health check mechanisms between clustered nodes, sometimes called "system actors",
147-
/// i.e. actors that serve the actor system directly.
147+
/// > i.e. actors that serve the actor system directly.
148148
///
149-
/// Next, we will discuss the the just mentioned resolve method, which is closely tied to readying actors.
149+
/// Next, we will discuss the just mentioned `resolve` method, which is closely tied to readying actors.
150150
///
151151
/// ### Resolving (potentially remote) Distributed Actors
152152
///
153153
/// An important functionality of any distributed actor system is being able to turn a ``DistributedActor`` type and ``ActorID``
154-
/// into an reference to such actor, regardless where the actor is located. The ID should have enough information stored
155-
/// to be able to make the decision _where_ the actor is located, without having to contact remote nodes. Specifically,
154+
/// into a reference to such actor, regardless where the actor is located. The ID should have enough information stored
155+
/// to be able to make the decision of _where_ the actor is located, without having to contact remote nodes. Specifically,
156156
/// the implementation of ``DistributedActorSystem/resolve(id:as:)`` is _not_ `async` and should _not_ perform long running
157157
/// or blocking operations in order to return.
158158
///
@@ -172,11 +172,11 @@ import _Concurrency
172172
/// `remoteCall(on:target:invocation:returning:throwing:)` (or `remoteCallVoid(on:target:invocation:throwing:)` for Void returning methods).
173173
///
174174
/// Implementing the remote calls correctly and efficiently is one of the most important tasks for a distributed actor system library.
175-
/// Since those methods are not currently expressible as protocol requirements Swift, and therefore will not appear in
176-
/// the protocol's documentation as explicit requirements, due to their advanced use of generics, we present their
177-
/// signatures that a conforming type one has to implement here:
175+
/// Since those methods are not currently expressible as protocol requirements in Swift due to their advanced use
176+
/// of generics, and therefore will not appear in the protocol's documentation as explicit requirements, we present
177+
/// their signatures that a conforming type has to implement here:
178178
///
179-
/// > Note: Although the the `remoteCall` methods are not expressed as protocol requirements in source,
179+
/// > Note: Although the `remoteCall` methods are not expressed as protocol requirements in source,
180180
/// > the compiler will provide the same errors as-if they were declared explicitly in this protocol.
181181
///
182182
/// ```swift
@@ -225,19 +225,19 @@ import _Concurrency
225225
/// Err: Error
226226
/// ```
227227
///
228-
/// Implementations of remote calls generally will serialize the `actor.id`, `target` and `invocation`
228+
/// Implementations of remote calls generally will serialize `actor.id`, `target` and `invocation`
229229
/// into some form of wire envelope, and send it over the network (or process boundary) using some
230-
/// transport mechanism of their choice. As they do so, they need to suspend the remoteCall function,
231-
/// and resume it once a reply to the call arrives; Unless the transport layer is also async/await aware,
230+
/// transport mechanism of their choice. As they do so, they need to suspend the `remoteCall` function,
231+
/// and resume it once a reply to the call arrives. Unless the transport layer is also async/await aware,
232232
/// this will often require making use of a ``CheckedContinuation``.
233233
///
234234
/// While implementing remote calls please keep in mind any potential failure scenarios that may occur,
235-
/// such as message loss, connection failures and similar issues. Such situations should all should be
236-
/// surfaced by resuming the remoteCall by throwing an error conforming to ``DistributedActorSystemError``.
235+
/// such as message loss, connection failures and similar issues. Such situations should all be
236+
/// surfaced by resuming the `remoteCall` by throwing an error conforming to ``DistributedActorSystemError``.
237237
///
238238
/// While it is not _required_ to conform error thrown out of these methods to ``DistributedActorSystemError``,
239239
/// the general guideline about conforming errors to this protocol is that errors which are outside of the user's control,
240-
/// but are thrown because transport or actor system issues happening, should conform to it. This is to simplify
240+
/// but are thrown because transport or actor system issues, should conform to it. This is to simplify
241241
/// separating "business logic errors" from transport errors.
242242
///
243243
///
@@ -253,9 +253,9 @@ public protocol DistributedActorSystem: Sendable {
253253
/// The type ID that will be assigned to any distributed actor managed by this actor system.
254254
///
255255
/// ### A note on Codable IDs
256-
/// If this type is Codable, then any `distributed actor` using this `ActorID` as its ``DistributedActor/ID``,
256+
/// If this type is ``Codable``, then any `distributed actor` using this `ActorID` as its ``DistributedActor/ID``
257257
/// will gain a synthesized ``Codable`` conformance which is implemented by encoding the `ID`.
258-
/// The decoding counter part of the Codable conformance is implemented by decoding the `ID` and passing it to
258+
/// The decoding counter part of the ``Codable`` conformance is implemented by decoding the `ID` and passing it to
259259
// the ``DistributedActor/resolve(id:using:)`` method.
260260
associatedtype ActorID: Sendable & Hashable
261261

@@ -823,7 +823,7 @@ public struct ExecuteDistributedTargetError: DistributedActorSystemError {
823823
/// Error thrown by distributed actor systems while encountering encoding/decoding
824824
/// issues.
825825
///
826-
/// Also thrown when attempt to decode ``DistributedActor`` is made,
826+
/// Also thrown when an attempt to decode ``DistributedActor`` is made,
827827
/// but no ``DistributedActorSystem`` is available in the `Decoder`'s
828828
/// `userInfo[.actorSystemKey]`, as it is required to perform the resolve call.
829829
@available(SwiftStdlib 5.7, *)

0 commit comments

Comments
 (0)