@@ -76,25 +76,7 @@ impl WorkflowSupervisor {
76
76
}
77
77
78
78
/// Update on start the set of pending commands
79
- pub fn load_pending_commands (
80
- & mut self ,
81
- mut commands : CommandBoard ,
82
- ) -> Vec < GenericCommandState > {
83
- // If the resumed commands have been triggered by an agent without workflow version management
84
- // then these commands are assigned the current version for the operation.
85
- // These currents versions have also to be marked as in use.
86
- for ( _, ref mut command) in commands. iter_mut ( ) {
87
- if command. workflow_version ( ) . is_none ( ) {
88
- if let Some ( versions) = command
89
- . operation ( )
90
- . and_then ( |operation| self . workflows . get_mut ( & operation. as_str ( ) . into ( ) ) )
91
- {
92
- if let Some ( current_version) = versions. use_current_version ( ) {
93
- * command = command. clone ( ) . set_workflow_version ( current_version) ;
94
- }
95
- }
96
- }
97
- }
79
+ pub fn load_pending_commands ( & mut self , commands : CommandBoard ) -> Vec < GenericCommandState > {
98
80
self . commands = commands;
99
81
self . commands
100
82
. iter ( )
@@ -150,6 +132,16 @@ impl WorkflowSupervisor {
150
132
}
151
133
}
152
134
135
+ /// Mark the current version of an operation workflow as being in use.
136
+ ///
137
+ /// Return the current version if any.
138
+ pub fn use_current_version ( & mut self , operation : & OperationName ) -> Option < WorkflowVersion > {
139
+ match self . workflows . get_mut ( & operation. as_str ( ) . into ( ) ) {
140
+ Some ( versions) => versions. use_current_version ( ) . cloned ( ) ,
141
+ None => None ,
142
+ }
143
+ }
144
+
153
145
/// Update the state of the command board on reception of a message sent by a peer over MQTT
154
146
///
155
147
/// Return the new CommandRequest state if any.
@@ -399,7 +391,7 @@ impl WorkflowVersions {
399
391
}
400
392
}
401
393
402
- // Mark the current version as being in-use.
394
+ /// Mark the current version as being in-use.
403
395
fn use_current_version ( & mut self ) -> Option < & WorkflowVersion > {
404
396
match self . current . as_ref ( ) {
405
397
Some ( ( version, workflow) ) => {
@@ -416,7 +408,7 @@ impl WorkflowVersions {
416
408
}
417
409
}
418
410
419
- // Remove the current version from this list of versions, restoring the built-in version if any
411
+ /// Remove the current version from this list of versions, restoring the built-in version if any
420
412
fn remove ( & mut self , version : & WorkflowVersion ) {
421
413
if self . current . as_ref ( ) . map ( |( v, _) | v == version) == Some ( true ) {
422
414
self . current = None ;
0 commit comments