You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move the docs pipeline to Swift 6.0 toolchains (#1192)
### Motivation:
The docs check pipeline was pinned to 5.10, because the 6.0 and newer
docc detected more issues in the docs, and pinning down was the
short-term workaround.
### Modifications:
- Stop pinning to 5.10, instead let it use 6.0 (and soon 6.1).
- Fix all the docs issues that 6.0 found.
### Result:
- Gets the CI back to green when using 6.0 docc:
https://github.com/apple/swift-distributed-actors/actions/runs/13986968195/job/39162333702?pr=1192
Copy file name to clipboardExpand all lines: Sources/DistributedCluster/Docs.docc/ClusterSingleton.md
+1-5
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,5 @@
1
1
# ``DistributedCluster/ClusterSingleton``
2
2
3
-
@Metadata {
4
-
@DocumentationExtension(mergeBehavior: append)
5
-
}
6
-
7
3
Allows for hosting a _single unique instance_ of a distributed actor within the entire distributed actor system,
8
4
including automatic fail-over when the node hosting the instance becomes down.
9
5
@@ -155,7 +151,7 @@ The allocated singleton instance will get the ``activateSingleton()-9fbad`` meth
155
151
156
152
Conversely, when the allocation strategy decides that this cluster member is no longer hosting the singleton the ``passivateSingleton()-31z1s`` method will be invoked and the actor will be released. Make sure to not retain the actor or make it perform any decisions which require single-point-of-truth after it has had passivate called on it, as it no longer is guaranteed to be the unique singleton instance anymore.
157
153
158
-
## Glossary
154
+
###Glossary
159
155
160
156
-**cluster singleton** - the conceptual "singleton". Regardless on which node it is located we can generally speak in terms of contacting the cluster singleton, by which we mean contacting a concrete active instance, wherever it is currently allocated.
161
157
- singleton **instance** - a concrete instance of a distributed actor, allocated as a singleton. In contrast to "cluster singleton", a "cluster singleton instance" refers to a concrete unique instance on a concrete unique member in the cluster.
Copy file name to clipboardExpand all lines: Sources/DistributedCluster/Docs.docc/Clustering.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Clustering multiple actor system instances into a single Distributed Actor Syste
6
6
7
7
In this article, we'll learn how to configure and use multiple ``ClusterSystem`` instances to form a distributed system.
8
8
9
-
## Initializing a ClusterSystem
9
+
###Initializing a ClusterSystem
10
10
11
11
In this section, we will discuss initializing and using a distributed cluster system.
12
12
@@ -49,15 +49,15 @@ Declaring a distributed actor is similar to declaring a plain `actor`. We do thi
49
49
50
50
TODO: documentation of TLS config
51
51
52
-
## Forming clusters
52
+
###Forming clusters
53
53
54
54
Forming a cluster is the first step towards making use of distributed clusters across multiple nodes.
55
55
56
56
Once a node joins at least one other node of an already established cluster, it will receive information about all other nodes
57
57
which participate in this cluster. This is why often it is not necessary to give all nodes the information about all other nodes in a cluster,
58
58
but only attempt to join one or a few of them. The first join "wins" and the cluster welcome the new node into the ``Cluster/Membership``.
59
59
60
-
### Joining existing nodes
60
+
####Joining existing nodes
61
61
62
62
In the simplest scenario we already know about some existing node that we can join to form a cluster, or become part of a cluster that node already is in.
63
63
@@ -83,7 +83,7 @@ There is also convenience APIs available on ``ClusterControl`` (`system.cluster`
83
83
-``ClusterControl/joined(endpoint:within:)`` which allows you to suspend until a specific node becomes ``Cluster/MemberStatus/joining`` in the cluster membership, or
84
84
-``ClusterControl/waitFor(_:_:within:)-2aq7r`` which allows you to suspend until a node reaches a specific ``Cluster/MemberStatus``.
85
85
86
-
### Automatic Node Discovery
86
+
####Automatic Node Discovery
87
87
88
88
The cluster system uses [swift-service-discovery](https://github.com/apple/swift-service-discovery) to discover nearby nodes it can connect to. This discovery step is only necessary to find IPs and ports on which we are expecting other cluster actor system instances to be running, the actual joining of the nodes is performed by the cluster itself. It can negotiate, and authenticate the other peer before establishing a connection with it (see also TODO: SECURITY).
89
89
@@ -106,7 +106,7 @@ Similarly, you can implement the [ServiceDiscovery](https://github.com/apple/swi
106
106
and this will then enable the cluster to locate nodes to contact and join automatically. It also benefits all other uses of service discovery in such new environment,
107
107
so we encourage publishing your implementations if you're able to!
108
108
109
-
## Cluster Events
109
+
###Cluster Events
110
110
111
111
Cluster events are events emitted by the cluster as changes happen to the lifecycle of members of the cluster.
112
112
@@ -186,7 +186,7 @@ The ``Cluster/Membership`` also offers a number of useful APIs to inspect the me
186
186
187
187
> A new async/await API might be offered that automates such "await for some node to reach some state" in the future, refer to [#948](https://github.com/apple/swift-distributed-actors/issues/948) for more details.
188
188
189
-
## Cluster Leadership
189
+
###Cluster Leadership
190
190
191
191
The cluster has a few operations which must be performed in a consistent fashion, such as moving a joining member to the ``Cluster/MemberStatus/up`` state. Other member status changes such as becoming `joining` or `down` do not require such strict decision-making and are disseminated throughout the cluster even without a leader.
192
192
@@ -197,7 +197,7 @@ For details, refer to the ``Leadership/LowestReachableMember`` documentation.
197
197
198
198
You can configure leader election by changing the ``ClusterSystemSettings/autoLeaderElection`` setting while initializing your ``ClusterSystem``.
199
199
200
-
## Customizing Remote Calls
200
+
###Customizing Remote Calls
201
201
202
202
Remote calls are at the heart of what makes distributed actors actually distributed.
Copy file name to clipboardExpand all lines: Sources/DistributedCluster/Docs.docc/Contributing.md
+6-4
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,20 @@
1
1
# Contributing
2
2
3
+
Learn how to contribute to this project.
3
4
5
+
## Overview
4
6
5
-
## Testing
7
+
###Testing
6
8
7
9
The cluster is extensively tested, including plain unit tests, tests spanning multiple nodes within the same process, as well as multi-node tests spanning across actor systems running across separate processes.
8
10
9
-
### Multi-node testing
11
+
####Multi-node testing
10
12
11
13
Multi node test infrastructure is still in development and may be lacking some features, however its basic premise is to be able to run small "apps" that function as tests, and are automatically deployed to multiple processes.
12
14
13
15
> Note: Eventually, those processes may actually be located on different physical machines, but this isn't implemented yet.
14
16
15
-
## Testing logging (LogCapture)
17
+
###Testing logging (LogCapture)
16
18
17
19
As the cluster performs operations "in the background", such as keeping the membership and health information of the cluster up to date, it is very important that log statements it emits in such mode are useful and actionable, byt not overwhelming.
to suspend until the expected log statement is emitted. It is possible to configure more details about the matching as well as timeouts by passing more parameters to this call.
Copy file name to clipboardExpand all lines: Sources/DistributedCluster/Docs.docc/Introduction.md
+12-13
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@ A high-level introduction to distributed actor systems.
6
6
7
7
Distributed actors extend Swift's "local only" concept of `actor` types to the world of distributed systems.
8
8
9
-
10
9
### Actors
11
10
12
11
As distributed actors are an extension of Swift's actor based concurrency model, it is recommended to familiarize yourself with Swift actors first, before diving into the world of distributed actors.
@@ -15,7 +14,7 @@ To do so, you can refer to:
15
14
-[Concurrency: Actors](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html#ID645) section of the Swift Book,
16
15
- or the [Protect mutable state with Swift actors](https://developer.apple.com/videos/play/wwdc2021/10133/) introduction video from WWDC 2021.
17
16
18
-
## Thinking in (distributed) actors
17
+
###Thinking in (distributed) actors
19
18
20
19
In order to build distributed systems successfully you will need to get into the right mindset.
21
20
@@ -25,7 +24,7 @@ Distribution comes with the added complexity of _partial failure_ of systems. Me
25
24
26
25
In this section we will try to guide you towards "thinking in actors," but perhaps it’s also best to first realize that: "you probably already know actors!" As any time you implement some form of identity that is given tasks that it should work on, most likely using some concurrent queue or other synchronization mechanism, you are probably inventing some form of actor-like structures there yourself!
27
26
28
-
## Distributed actors
27
+
###Distributed actors
29
28
30
29
Distributed actors are a type of nominal type in Swift. Similarly to actors, they are introduced using the `distributed actor` pair of keywords.
31
30
@@ -41,7 +40,7 @@ distributed actor Greeter {
41
40
}
42
41
```
43
42
44
-
### Module-wide default actor system typealias
43
+
####Module-wide default actor system typealias
45
44
46
45
Instead of declaring the `typealias ActorSystem = ClusterSystem` in every actor you declare, you can instead declare a module-wide `DefaultDistributedActorSystem` typealias instead. Generally it is recommended to keep that type-alias at the default (module wide) access control level, like this:
47
46
@@ -77,13 +76,13 @@ distributed actor WebSocketWorker {
77
76
}
78
77
```
79
78
80
-
### Location Transparency
79
+
####Location Transparency
81
80
82
81
Distributed actors gain most of their features from the fact that they can be interacted with "the same way" (only by asynchronous and throwing `distributed func` calls), regardless where they are "located". This means that if one is passed an instance of a `distributed actor Greeter` we do not know (by design and on purpose!) if it is really a local instance, or actually only a reference to a remote distributed actor, located on some other host.
83
82
84
83
This capability along with strong isolation guarantees, enables a concept called [location transparency](https://en.wikipedia.org/wiki/Location_transparency), which is a programming style in which we describe network resources by some form of identity, and not their actual location. In distributed actors, this means that practically speaking, we do not have to know "where" a distributed actor is located. Or in some more advanced patterns, it may actually be "moving" from one host to another, while we still only refer to it using some abstract identifier.
85
84
86
-
## Distributed actor isolation
85
+
###Distributed actor isolation
87
86
88
87
In order to function properly, distributed actors must impose stronger isolation guarantees than their local-only cousins.
89
88
@@ -144,7 +143,7 @@ distributed actor Example {
144
143
145
144
It is possible to declare nonisolated computed properties as well as methods, and they follow the same rules as such declarations in actor types.
146
145
147
-
## Distributed actor initialization
146
+
###Distributed actor initialization
148
147
149
148
Distributed actors **must** declare a type of `ActorSystem` they are intended to be used with (which in case of the swift-distributed-actors cluster library is always the ``ClusterSystem``), and initialize the implicit `actorSystem` property that stores the system.
Distributed actor initializers are allowed to be throwing, failing, or even `async`. For more details on actor initializer semantics, please refer to [SE-0327: On Actors and Initialization](https://github.com/apple/swift-evolution/blob/main/proposals/0327-actor-initializers.md).
161
160
162
-
## Distributed actor methods
161
+
###Distributed actor methods
163
162
164
163
Distributed actors may declare distributed instance methods by prepending the `distributed` keyword in front of a `func` or _computed property_ declaration, like so:
165
164
@@ -217,11 +216,11 @@ The `self.work(on:)` call still needed to use the `await` keyword, since we were
217
216
> try await worker.work(item, settings)
218
217
> ```
219
218
220
-
## Distributed actors conforming to protocols
219
+
### Distributed actors conforming to protocols
221
220
222
221
Distributed actors may conform to `protocol` types, however they face similar restrictions in doing so as local-only `actor` types do.
223
222
224
-
### Witnessing protocol requirements
223
+
#### Witnessing protocol requirements
225
224
226
225
As distributed actor methods are implicitly asynchronous and throwing when called from the outside of the actor, they can only witness asynchronous and throwing protocol requirements.
227
226
@@ -247,7 +246,7 @@ distributed actor Example: SampleProtocol {
247
246
}
248
247
```
249
248
250
-
### Synchronous protocol requirements
249
+
####Synchronous protocol requirements
251
250
252
251
A `distributed actor` may conform to a synchronous protocol requirement **only** with a `nonisolated` computed property or function declaration.
253
252
@@ -268,7 +267,7 @@ This is correct, since it is only accessing other `nonisolated` computed propert
268
267
>
269
268
> This is also how the `Hashable` and `Equatable` protocols are implemented for distributed actors, by delegating to the `self.id` property.
270
269
271
-
### DistributedActor constrained protocols
270
+
####DistributedActor constrained protocols
272
271
273
272
Protocols may require that types extending it be distributed actors, this can be expressed using the following:
274
273
@@ -294,7 +293,7 @@ However, the `DistributedActor` **does not** refine the `Actor` protocol! This i
294
293
295
294
In practice, we do not see this as a problem, but a natural fallout of the isolation models. If necessary to require a type to be "some actor", please use the `protocol Worker: AnyActor` constraint.
Copy file name to clipboardExpand all lines: Sources/DistributedCluster/Docs.docc/Lifecycle.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Monitoring distributed actor lifecycles enables you to react to their terminatio
9
9
This is crucial for building robust actor systems which are able to automatically remote e.g. remote worker references as they are confirmed to have terminated.
10
10
This can happen if the remote actor is just deinitialized, or if the remote host is determined to be ``Cluster/MemberStatus/down``.
11
11
12
-
## Lifecycle Watch
12
+
###Lifecycle Watch
13
13
14
14
A distributed actor is able to monitor other distributed actors by making use of the ``LifecycleWatch`` protocol.
Copy file name to clipboardExpand all lines: Sources/DistributedCluster/Docs.docc/Security.md
+5-6
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Configuring security aspects of your cluster system.
11
11
Securing your cluster system mostly centers around two concepts: making sure you trust your peers and systems which are able to call into the cluster,
12
12
and ensuring that messages exchanged are of trusted types.
13
13
14
-
## Transport Security: TLS
14
+
###Transport Security: TLS
15
15
16
16
> Note: **TODO:** explain configuring TLS
17
17
@@ -48,18 +48,18 @@ let tlsExampleSystem = await ClusterSystem("tls-example") { settings in
48
48
}
49
49
```
50
50
51
-
## Message Security
51
+
###Message Security
52
52
53
53
The other layer of security is about messages which are allowed to be sent to actors.
54
54
55
55
In general, you can audit your distributed API surface by searching your codebase for `distributed func` and `distributed var`, and verify the types involved in those calls.
56
56
57
57
The cluster also requires all types invokved in remote calls to conform to `Codable` and will utilize `Encoder` and `Decoder` types to deserialize them. As such, the typical attack of "accidentally deserialize an arbitrary sub-class of a type" is prevented by the `Codable` type itself.
58
58
59
-
### Trusting message types
59
+
####Trusting message types
60
60
61
61
62
-
### Trusting error types
62
+
####Trusting error types
63
63
64
64
Error types may be transported back to a remote caller if they are trusted.
0 commit comments