diff options
| author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-10-10 17:20:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-10 17:20:30 +0200 |
| commit | 5a8a989b7815023f33a1e3183a55cc8999af5d98 (patch) | |
| tree | d15619ed83a2965f17dc10a78c9072f34d393009 /core/ops_json.rs | |
| parent | f2ac7ff23a2ae4925f4ca32ffd61c923c481ef4e (diff) | |
refactor(metrics): move to core (#12386)
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
Diffstat (limited to 'core/ops_json.rs')
| -rw-r--r-- | core/ops_json.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/ops_json.rs b/core/ops_json.rs index 22a84154d..0ca7e5ce4 100644 --- a/core/ops_json.rs +++ b/core/ops_json.rs @@ -32,9 +32,10 @@ pub fn void_op_async() -> Box<OpFn> { // to deserialize to the unit type instead of failing with `ExpectedNull` // op_async(|_, _: (), _: ()| futures::future::ok(())) Box::new(move |state, payload| -> Op { + let op_id = payload.op_id; let pid = payload.promise_id; let op_result = serialize_op_result(Ok(()), state); - Op::Async(Box::pin(futures::future::ready((pid, op_result)))) + Op::Async(Box::pin(futures::future::ready((pid, op_id, op_result)))) }) } @@ -112,6 +113,7 @@ where RV: Serialize + 'static, { Box::new(move |state, payload| -> Op { + let op_id = payload.op_id; let pid = payload.promise_id; // Deserialize args, sync error on failure let args = match payload.deserialize() { @@ -124,7 +126,7 @@ where use crate::futures::FutureExt; let fut = op_fn(state.clone(), a, b) - .map(move |result| (pid, serialize_op_result(result, state))); + .map(move |result| (pid, op_id, serialize_op_result(result, state))); Op::Async(Box::pin(fut)) }) } @@ -143,6 +145,7 @@ where RV: Serialize + 'static, { Box::new(move |state, payload| -> Op { + let op_id = payload.op_id; let pid = payload.promise_id; // Deserialize args, sync error on failure let args = match payload.deserialize() { @@ -155,7 +158,7 @@ where use crate::futures::FutureExt; let fut = op_fn(state.clone(), a, b) - .map(move |result| (pid, serialize_op_result(result, state))); + .map(move |result| (pid, op_id, serialize_op_result(result, state))); Op::AsyncUnref(Box::pin(fut)) }) } |
