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
Copy file name to clipboardexpand all lines: README.md
+99-6
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ Python User Language Support for [Spawn](https://github.com/eigr/spawn).
7
7
2.[Getting Started](#getting-started)
8
8
3.[Advanced Use Cases](#advanced-use-cases)
9
9
-[Types of Actors](#types-of-actors)
10
-
-[Side Effects](#side-effects)
11
10
-[Broadcast](#broadcast)
11
+
-[Side Effects](#side-effects)
12
12
-[Forward](#forward)
13
13
-[Pipe](#pipe)
14
14
4.[Using Actors](#using-actors)
@@ -163,9 +163,6 @@ First we need to understand how the various types of actors available in Spawn b
163
163
164
164
***Pooled Actors**: Pooled Actors, as the name suggests, are a collection of actors that are grouped under the same name assigned to them at compile time. Pooled actors are generally used when higher performance is needed and are also recommended for handling serverless loads.
165
165
166
-
### Side Effects
167
-
TODO
168
-
169
166
### Broadcast
170
167
171
168
Actors in Spawn can subscribe to a thread and receive, as well as broadcast, events for a given thread.
Side effects such as broadcast are not part of the response flow to the caller. They are request-asynchronous events that are emitted after the Actor's state has been saved in memory.
261
+
224
262
### Forward
225
-
TODO
263
+
264
+
Actors can route some actions to other actors as part of their response. For example, sometimes you may want another Actor to be responsible for processing a message that another Actor has received. We call this forwarding and it occurs when we want to forward the input argument of a request that a specific Actor has received to the input of an action in another Actor.
265
+
266
+
See an example:
267
+
268
+
```python
269
+
from domain.domain_pb2 import Request
270
+
271
+
from spawn.eigr.functions.actors.api.actor import Actor
272
+
from spawn.eigr.functions.actors.api.settings import ActorSettings
273
+
from spawn.eigr.functions.actors.api.context import Context
274
+
from spawn.eigr.functions.actors.api.value import Value
275
+
from spawn.eigr.functions.actors.api.workflows.forward import Forward
276
+
277
+
actor = Actor(settings=ActorSettings(name="joe", stateful=True))
Similarly, sometimes we want to chain a request through several different processes. For example forwarding an actor's computational output as another actor's input. There is this type of routing we call Pipe, as the name suggests, a pipe forwards what would be the response of the received request to the input of another Action in another Actor.
289
+
In the end, just like in a Forward, it is the response of the last Actor in the chain of routing to the original caller.
290
+
291
+
Example:
292
+
293
+
```python
294
+
from domain.domain_pb2 import State, Request, Reply
295
+
296
+
from spawn.eigr.functions.actors.api.actor import Actor
297
+
from spawn.eigr.functions.actors.api.settings import ActorSettings
298
+
from spawn.eigr.functions.actors.api.context import Context
299
+
from spawn.eigr.functions.actors.api.value import Value
300
+
from spawn.eigr.functions.actors.api.workflows.pipe import Pipe
301
+
302
+
actor = Actor(settings=ActorSettings(name="joe", stateful=True))
0 commit comments