@@ -41,13 +41,32 @@ distributed actor Worker: LifecycleWatch {
41
41
42
42
@main struct Main {
43
43
static func main( ) async {
44
- let worker : any LifecycleWatch = Worker ( actorSystem: DefaultDistributedActorSystem ( ) )
44
+ let actorSystem = DefaultDistributedActorSystem ( )
45
+
46
+ let worker : any LifecycleWatch = Worker ( actorSystem: actorSystem)
45
47
try ! await worker. test ( x: 42 , " on protocol " )
46
48
47
49
// CHECK: executed: test(x:_:)
48
50
// CHECK: executed: watch(x:_:) - x = 42, y = on protocol
49
51
// CHECK: done executed: test(x:_:)
50
52
53
+ // ==== --------------------------------------------------------------------
54
+
55
+ let remote = try ! Worker . resolve ( id: worker. id, using: actorSystem)
56
+ try ! await remote. test ( x: 42 , " direct " ) // Remote call
57
+ // CHECK: >> remoteCallVoid: on:main.Worker, target:test(x:_:)
58
+ // CHECK: << onReturnVoid: ()
59
+
60
+ let remoteAny : any LifecycleWatch = remote
61
+ try ! await remoteAny. test ( x: 42 , " direct " ) // Remote call
62
+ // CHECK: >> remoteCallVoid: on:main.Worker, target:test(x:_:)
63
+ // CHECK: << onReturnVoid: ()
64
+
65
+ let remoteAnyOptional : ( any LifecycleWatch ) ? = remote
66
+ try ! await remoteAnyOptional? . test ( x: 42 , " direct " ) // Remote call
67
+ // CHECK: >> remoteCallVoid: on:main.Worker, target:test(x:_:)
68
+ // CHECK: << onReturnVoid: ()
69
+
51
70
print ( " OK " ) // CHECK: OK
52
71
}
53
72
}
0 commit comments