|
1 | 1 | use super::dispatch::*; |
2 | 2 | use super::http::*; |
3 | 3 | use super::*; |
4 | | -use crate::error::{client_error_message, ProtocolError}; |
| 4 | +use crate::error::{ProtocolError, client_error_message}; |
5 | 5 | use ::http; |
6 | 6 |
|
7 | 7 | #[derive(rivet_error::RivetError, serde::Serialize)] |
@@ -127,6 +127,30 @@ impl RegistryDispatcher { |
127 | 127 | }; |
128 | 128 | json_http_response(StatusCode::OK, &payload) |
129 | 129 | } |
| 130 | + (http::Method::DELETE, "/inspector/queue") => { |
| 131 | + match instance.ctx.queue().reset().await { |
| 132 | + Ok(_) => json_http_response(StatusCode::OK, &json!({})), |
| 133 | + Err(error) => Err(error).context("reset inspector queue"), |
| 134 | + } |
| 135 | + } |
| 136 | + (http::Method::POST, "/inspector/queue") => { |
| 137 | + let body: InspectorEnqueueBody = match parse_json_body(request) { |
| 138 | + Ok(body) => body, |
| 139 | + Err(response) => return Ok(Some(response)), |
| 140 | + }; |
| 141 | + let cbor_body = encode_json_as_cbor(&body.body.unwrap_or(serde_json::Value::Null))?; |
| 142 | + match instance.ctx.queue().send(&body.name, &cbor_body).await { |
| 143 | + Ok(message) => json_http_response( |
| 144 | + StatusCode::OK, |
| 145 | + &json!({ |
| 146 | + "id": message.id, |
| 147 | + "name": message.name, |
| 148 | + "createdAtMs": message.created_at, |
| 149 | + }), |
| 150 | + ), |
| 151 | + Err(error) => Err(error).context("enqueue inspector queue message"), |
| 152 | + } |
| 153 | + } |
130 | 154 | (http::Method::GET, "/inspector/workflow-history") => self |
131 | 155 | .inspector_workflow_history(instance) |
132 | 156 | .await |
@@ -346,9 +370,7 @@ impl RegistryDispatcher { |
346 | 370 | ) -> Result<(bool, Option<Vec<u8>>)> { |
347 | 371 | let result = instance |
348 | 372 | .ctx |
349 | | - .internal_keep_awake(dispatch_workflow_history_through_task( |
350 | | - &instance.dispatch, |
351 | | - )) |
| 373 | + .internal_keep_awake(dispatch_workflow_history_through_task(&instance.dispatch)) |
352 | 374 | .await |
353 | 375 | .context("load inspector workflow history"); |
354 | 376 |
|
|
0 commit comments