@@ -9,12 +9,12 @@ use api_framework::{
99} ;
1010
1111use axum:: { Json , http:: StatusCode , response:: IntoResponse } ;
12- use config_file:: FromConfigFile ;
12+ use config_file:: FromConfigFile as _ ;
1313use serde:: Deserialize ;
1414
1515use crate :: {
1616 config:: {
17- Config ,
17+ Config as _ ,
1818 services:: { ServiceConfig , ServicesConfig } ,
1919 } ,
2020 env:: DOCKER_WORKSPACE_DIR ,
@@ -52,8 +52,8 @@ pub async fn post(Json(payload): Json<PostPayload>) -> impl IntoResponse {
5252 let service = match services
5353 . services
5454 . iter ( )
55- . cloned ( )
5655 . find ( |s| s. service_label == payload. service_label )
56+ . cloned ( )
5757 {
5858 Some ( s) => s,
5959 None => {
@@ -65,11 +65,22 @@ pub async fn post(Json(payload): Json<PostPayload>) -> impl IntoResponse {
6565 }
6666 } ;
6767
68- tokio:: spawn ( QUEUED_ASYNC . run ( payload. service_label . clone ( ) , move |cx| {
69- Box :: pin ( post_transaction ( cx, payload. clone ( ) , service. clone ( ) ) )
70- } ) ) ;
71-
72- StatusCode :: OK . into_response ( )
68+ match QUEUED_ASYNC
69+ . run ( payload. service_label . clone ( ) , move |cx| {
70+ Box :: pin ( post_transaction ( cx, payload. clone ( ) , service. clone ( ) ) )
71+ } )
72+ . await
73+ {
74+ Ok ( _) => StatusCode :: OK . into_response ( ) ,
75+ Err ( _) => {
76+ tracing:: error!( "failed to queue update transaction" ) ;
77+ (
78+ StatusCode :: INTERNAL_SERVER_ERROR ,
79+ "failed to queue update transaction" ,
80+ )
81+ . into_response ( )
82+ }
83+ }
7384}
7485
7586async fn post_transaction (
@@ -79,7 +90,7 @@ async fn post_transaction(
7990) -> StateResult < ( ) > {
8091 async fn inner ( cx : & QueuedAsyncFrameworkContext , service : & ServiceConfig ) -> StateResult < ( ) > {
8192 // cd to workspace
82- transactions:: sys:: cd ( & * DOCKER_WORKSPACE_DIR )
93+ transactions:: sys:: cd ( & DOCKER_WORKSPACE_DIR )
8394 . await
8495 . map_err ( |_| StateError :: Retry ) ?;
8596
@@ -102,6 +113,9 @@ async fn post_transaction(
102113 . await
103114 . map_err ( |_| StateError :: Retry ) ?;
104115
116+ // logout from docker
117+ transactions:: docker:: logout ( ) . await . ok ( ) ;
118+
105119 Ok ( ( ) )
106120 }
107121
0 commit comments