Commit e1b328e
committed
[hyperactor] mesh: define
Pull Request resolved: #1841
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
ghstack-source-id: 323206577
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!resource::Resource, and mesh::Mesh in terms of it1 parent 38ca2a2 commit e1b328e
2 files changed
+27
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
362 | 379 | | |
363 | 380 | | |
364 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | | - | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| |||
49 | 47 | | |
50 | 48 | | |
51 | 49 | | |
52 | | - | |
| 50 | + | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
63 | 58 | | |
64 | 59 | | |
65 | 60 | | |
| |||
68 | 63 | | |
69 | 64 | | |
70 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| |||
0 commit comments