@@ -829,8 +829,7 @@ impl DownstairsClient {
829
829
}
830
830
831
831
/// Checks whether the client is accepting IO
832
- #[ must_use]
833
- pub fn should_send ( & self ) -> ShouldSendResult {
832
+ pub fn should_send ( & self ) -> Result < EnqueueResult , ShouldSendError > {
834
833
match self . state {
835
834
// We never send jobs if we're in certain inactive states
836
835
DsState :: Connecting {
@@ -839,7 +838,7 @@ impl DownstairsClient {
839
838
} if self . cfg . read_only => {
840
839
// Read only upstairs can connect with just a single downstairs
841
840
// ready, we skip jobs on the other downstairs till they connect.
842
- ShouldSendResult :: Skip
841
+ Ok ( EnqueueResult :: Skip )
843
842
}
844
843
DsState :: Connecting {
845
844
mode : ConnectionMode :: Faulted | ConnectionMode :: Replaced ,
@@ -850,13 +849,13 @@ impl DownstairsClient {
850
849
| ClientStopReason :: Disabled
851
850
| ClientStopReason :: Replacing
852
851
| ClientStopReason :: NegotiationFailed ( ..) ,
853
- ) => ShouldSendResult :: Skip ,
852
+ ) => Ok ( EnqueueResult :: Skip ) ,
854
853
855
854
// Send jobs if the client is active or in live-repair. The caller
856
855
// is responsible for checking whether live-repair jobs should be
857
856
// skipped, and this happens outside of this function
858
- DsState :: Active => ShouldSendResult :: Send ,
859
- DsState :: LiveRepair => ShouldSendResult :: CheckLiveRepair ,
857
+ DsState :: Active => Ok ( EnqueueResult :: Send ) ,
858
+ DsState :: LiveRepair => Err ( ShouldSendError :: InLiveRepair ) ,
860
859
861
860
// Holding jobs for an offline client means that those jobs are
862
861
// marked as InProgress, so they aren't cleared out by a subsequent
@@ -865,7 +864,7 @@ impl DownstairsClient {
865
864
DsState :: Connecting {
866
865
mode : ConnectionMode :: Offline ,
867
866
..
868
- } => ShouldSendResult :: Hold ,
867
+ } => Ok ( EnqueueResult :: Hold ) ,
869
868
870
869
DsState :: Stopping ( ClientStopReason :: Deactivated )
871
870
| DsState :: Connecting {
@@ -2009,7 +2008,7 @@ pub(crate) enum NegotiationResult {
2009
2008
LiveRepair ,
2010
2009
}
2011
2010
2012
- /// Result value from [`DownstairsClient::enqueue `]
2011
+ /// Success value from [`DownstairsClient::should_send `]
2013
2012
#[ derive( Copy , Clone ) ]
2014
2013
pub ( crate ) enum EnqueueResult {
2015
2014
/// The given job should be marked as in progress and sent
@@ -2026,18 +2025,11 @@ pub(crate) enum EnqueueResult {
2026
2025
Skip ,
2027
2026
}
2028
2027
2029
- /// Result value from [`DownstairsClient::should_send`]
2030
- ///
2031
- /// This is a superset of [`EnqueueResult`], which includes a value indicating
2032
- /// that the client is in live-repair and the caller should figure it out based
2033
- /// on the last active live-repair extent.
2034
- pub ( crate ) enum ShouldSendResult {
2035
- Send ,
2036
- Hold ,
2037
- Skip ,
2038
-
2028
+ /// Error result from [`DownstairsClient::should_send`]
2029
+ #[ derive( Copy , Clone ) ]
2030
+ pub ( crate ) enum ShouldSendError {
2039
2031
/// The caller should check against our active live-repair extent
2040
- CheckLiveRepair ,
2032
+ InLiveRepair ,
2041
2033
}
2042
2034
2043
2035
impl EnqueueResult {
0 commit comments