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
[hyperactor] mesh: define resource::Resource, and mesh::Mesh in terms of it
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: 323030040
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/)!
0 commit comments