@@ -34,30 +34,6 @@ pub mod builder;
3434pub mod starter;
3535pub mod stopper;
3636
37- /// Defines the error to be returned when there is a problem applying configuration
38- /// to a supervisor.
39- ///
40- /// # Usage Example
41- ///
42- /// ```rust,ìgnore
43- /// let supervisor = match supervisor.apply(effective_agent) {
44- /// Ok(new_supervisor) => new_supervisor,
45- /// Err(apply_err) => {
46- /// warn!("Error applying effective agent: {}", apply_err.reason)
47- /// apply_err.supervisor
48- /// }
49- /// }
50- /// ```
51- #[ derive( thiserror:: Error ) ]
52- #[ error( "failure applying configuration to supervisor: {reason}" ) ]
53- pub struct ApplyError < S : Supervisor > {
54- /// Reason explaining the issue
55- pub reason : String ,
56- /// Supervisor should keep be kept as a result of the failed applied. It can be
57- /// the previous supervisor.
58- pub supervisor : S ,
59- }
60-
6137/// Constructs a supervisor for managing sub-agent lifecycle.
6238///
6339/// This trait is responsible for building a supervisor starter based on an effective agent
@@ -135,6 +111,7 @@ pub trait SupervisorStarter {
135111/// * `ApplyError` - The error type returned when applying configuration changes fails
136112/// * `StopError` - The error type returned when stopping fails
137113pub trait Supervisor : Sized {
114+ type ApplyError : Error ;
138115 type StopError : Error ;
139116
140117 /// Applies a new effective agent configuration to the running supervisor.
@@ -153,11 +130,9 @@ pub trait Supervisor: Sized {
153130 /// # Returns
154131 ///
155132 /// * `Ok(Self)` - A supervisor instance with the new configuration applied
156- /// * `Err(ApplyError)` - If there is an error applying the configuration. [ApplyError] contains the
157- /// [Supervisor] that is expected to keep running along with the reason why the configuration failed,
158- /// the could be `self` or a different supervisor, allowing a recovery mechanism in case of failure.
133+ /// * `Err(Self::ApplyError)` - If there is an error applying the configuration.
159134 ///
160- fn apply ( self , effective_agent : EffectiveAgent ) -> Result < Self , ApplyError < Self > > ;
135+ fn apply ( self , effective_agent : EffectiveAgent ) -> Result < Self , Self :: ApplyError > ;
161136
162137 /// Stops the supervisor and cleans up all associated resources.
163138 ///
0 commit comments