Commit e921dcc
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: 322871728
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 5f11cd2 commit e921dcc
2 files changed
+27
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
337 | 354 | | |
338 | 355 | | |
339 | 356 | | |
| |||
| 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