Add batch submitter subcomponent traits
Adds traits to make the submission command swappable based on the batch
submitter configuration.
// See the License for the specific language governing permissions and
// limitations under the License.
+use async_trait::async_trait;
+
use std::fmt;
use crate::{batch_submission::Submission, scope_id::ScopeId};
@@ -86,3 +88,14 @@ struct ErrorResponse<S: ScopeId> {
scope_id: S,
error: String,
}
+
+// Subcomponent traits
+
+trait ExecuteCommandFactory<S: ScopeId>: Sync + Send {
+ fn new_command(&self, submission: Submission<S>) -> Box<dyn ExecuteCommand<S>>;
+}
+
+#[async_trait]
+trait ExecuteCommand<S: ScopeId>: fmt::Debug + Sync + Send {
+ async fn execute(&mut self) -> Result<SubmissionResponse<S>, reqwest::Error>;
+}
