MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / handle_pr_start_req

Function handle_pr_start_req

chirpstack/src/api/backend/mod.rs:210–249  ·  view source on GitHub ↗
(
    sender_client: Arc<backend::Client>,
    bp: backend::BasePayload,
    b: &[u8],
)

Source from the content-addressed store, hash-verified

208}
209
210async fn handle_pr_start_req(
211 sender_client: Arc<backend::Client>,
212 bp: backend::BasePayload,
213 b: &[u8],
214) -> Response {
215 if sender_client.is_async() {
216 let b = b.to_vec();
217 task::spawn(async move {
218 let ans = match _handle_pr_start_req(&b).await {
219 Ok(v) => v,
220 Err(e) => {
221 let msg = e.to_string();
222 backend::PRStartAnsPayload {
223 base: bp.to_base_payload_result(err_to_result_code(e), &msg),
224 ..Default::default()
225 }
226 }
227 };
228
229 log_request_response(&bp, &b, &ans).await;
230
231 if let Err(e) = sender_client.pr_start_ans(backend::Role::FNS, &ans).await {
232 error!(error = %e.full(), transaction_id = bp.transaction_id, "Send async PRStartAns error");
233 }
234 });
235 (StatusCode::OK, "").into_response()
236 } else {
237 match _handle_pr_start_req(b).await {
238 Ok(ans) => {
239 log_request_response(&bp, b, &ans).await;
240 Json(&ans).into_response()
241 }
242 Err(e) => {
243 let ans = err_to_response(e, &bp);
244 log_request_response(&bp, b, &ans).await;
245 Json(&ans).into_response()
246 }
247 }
248 }
249}
250
251async fn _handle_pr_start_req(b: &[u8]) -> Result<backend::PRStartAnsPayload> {
252 let pl: backend::PRStartReqPayload = serde_json::from_slice(b)?;

Callers 1

_handle_requestFunction · 0.85

Calls 9

_handle_pr_start_reqFunction · 0.85
err_to_result_codeFunction · 0.85
log_request_responseFunction · 0.85
err_to_responseFunction · 0.85
is_asyncMethod · 0.80
to_stringMethod · 0.80
pr_start_ansMethod · 0.80
to_vecMethod · 0.45

Tested by

no test coverage detected