Skip to content

Commit 611fe98

Browse files
books: hyperactor-book: note about attest (#441)
Summary: Pull Request resolved: #441 looks like i failed to actually commit the change requested in https://www.internalfb.com/diff/D77744864?dst_version_fbid=708027588783326&transaction_fbid=697159643193767. this fixes it and also improves the typed references PortRef and OncePortRef introductions to mention that their message types require `RemoteMessage`. Reviewed By: mariusae Differential Revision: D77864737 fbshipit-source-id: 8d27858eb327c8753543636d5fb0ddfc6b05e509
1 parent baec2f4 commit 611fe98

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

books/hyperactor-book/src/references/typed_refs.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Typed references are strongly typed wrappers over raw identifiers like `ActorId`
77
There are three main typed reference types:
88

99
- [`ActorRef<A>`](#actorrefa): A typed reference to an actor implementing the `RemoteActor` trait.
10-
- [`PortRef<M>`](#portrefm): A reference to a reusable mailbox port for messages of type `M`.
11-
- [`OncePortRef<M>`](#onceportrefm): A reference to a one-shot port for receiving a single response of type `M`.
10+
- [`PortRef<M>`](#portrefm): A reference to a reusable mailbox port for messages of type `M` implementing the `RemoteMessage` trait.
11+
- [`OncePortRef<M>`](#onceportrefm): A reference to a one-shot port for receiving a single response of type `M` implementing the `RemoteMessage` trait.
1212

1313
These types are used as parameters in messages, return values from bindings, and components of the routing system.
1414

@@ -22,6 +22,8 @@ These types are used as parameters in messages, return values from bindings, and
2222
let actor_ref: ActorRef<MyActor> = ActorRef::attest(actor_id);
2323
```
2424

25+
> **Note**: While `ActorRef::attest` can be used to construct a reference from an `ActorId`, it should generally be avoided. Instead, prefer using the `ActorRef` returned from `ActorHandle::bind()`, which guarantees that the actor is actually running and bound to a mailbox. `attest` is unsafe in the sense that it bypasses that guarantee.
26+
2527
Unlike `ActorHandle<A>`, an `ActorRef` is just a reference — it doesn’t guarantee that the actor is currently running. It's primarily used for routing and type-safe messaging across `Proc`s.
2628

2729
### Definition
@@ -48,8 +50,9 @@ This allows the port to be sent across the network or passed into other messages
4850

4951
```rust
5052
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
51-
pub struct PortRef<M: Message> {
53+
pub struct PortRef<M: RemoteMessage> {
5254
port_id: PortId,
55+
reducer_spec: Option<ReducerSpec>,
5356
phantom: PhantomData<M>,
5457
}
5558
```

0 commit comments

Comments
 (0)