(
&self,
job_id: &str,
request: &DispatchRequest,
)
| 611 | Ok((response, Box::pin(stream))) |
| 612 | } |
| 613 | |
| 614 | #[cfg(not(feature = "lambda"))] |
| 615 | async fn dispatch_lambda_invoke( |
| 616 | &self, |
| 617 | _job_id: &str, |
| 618 | _request: &DispatchRequest, |
| 619 | ) -> Result<DispatchResponse, DispatchError> { |
| 620 | Err(DispatchError::Configuration( |
| 621 | "Lambda SDK invoke requires the 'lambda' feature. Use HTTP backend with Lambda Function URLs instead.".into(), |
| 622 | )) |
| 623 | } |
| 624 | |
| 625 | /// Dispatch via Kubernetes Job creation |
| 626 | #[cfg(feature = "kubernetes")] |
| 627 | async fn dispatch_k8s_job( |
| 628 | &self, |
| 629 | job_id: &str, |
| 630 | request: &DispatchRequest, |
| 631 | ) -> Result<DispatchResponse, DispatchError> { |
| 632 | use crate::kubernetes::{ |
| 633 | ExecutionContext, JobDispatcher, JobMode, KubernetesConfig, SubmitJobRequest, |
| 634 | }; |
| 635 | |
| 636 | let k8s_config = KubernetesConfig::from_env(); |
| 637 | let dispatcher = JobDispatcher::new(k8s_config); |
| 638 | |
| 639 | let k8s_request = SubmitJobRequest { |
| 640 | run_id: request.run_id.clone(), |
| 641 | app_id: request.app_id.clone(), |
| 642 | board_id: request.board_id.clone(), |
| 643 | event_id: None, |
| 644 | version: request |
| 645 | .board_version |
| 646 | .map(|(major, minor, patch)| format!("{major}.{minor}.{patch}")), |
| 647 | payload: request.payload.clone(), |
| 648 | mode: JobMode::Isolated, |
| 649 | user_id: request.user_id.clone(), |
| 650 | execution_context: ExecutionContext { |
| 651 | credentials_json: request.credentials_json.clone(), |
| 652 | jwt: request.jwt.clone(), |
| 653 | callback_url: request.callback_url.clone(), |
| 654 | }, |
| 655 | }; |
| 656 | |
| 657 | dispatcher |
| 658 | .submit(k8s_request) |
| 659 | .await |
| 660 | .map_err(|e| DispatchError::Kubernetes(e.to_string()))?; |
| 661 | |
| 662 | Ok(DispatchResponse { |
| 663 | job_id: job_id.to_string(), |
| 664 | status: "created".into(), |
| 665 | backend: "kubernetes_job".into(), |
| 666 | }) |
| 667 | } |
| 668 | |
| 669 | #[cfg(not(feature = "kubernetes"))] |
| 670 | async fn dispatch_k8s_job( |
no test coverage detected