Skip to content

Commit 82da95c

Browse files
Improve formatting of sleep durations
1 parent c698519 commit 82da95c

File tree

1 file changed

+14
-4
lines changed
  • sdk-shared-core-wasm-bindings/src

1 file changed

+14
-4
lines changed

sdk-shared-core-wasm-bindings/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::convert::{Infallible, Into};
1111
use std::io::Write;
1212
use std::time::Duration;
1313
use tracing::metadata::LevelFilter;
14-
use tracing::{info, Dispatch, Level, Subscriber};
14+
use tracing::{Dispatch, Level, Subscriber};
1515
use tracing_subscriber::fmt::format::FmtSpan;
1616
use tracing_subscriber::fmt::MakeWriter;
1717
use tracing_subscriber::layer::SubscriberExt;
@@ -410,6 +410,9 @@ impl WasmVM {
410410
Some(Value::CombinatorResult(handles)) => WasmAsyncResultValue::CombinatorResult(
411411
handles.into_iter().map(Into::into).collect(),
412412
),
413+
_ => {
414+
panic!("Unsupported yet")
415+
}
413416
},
414417
)
415418
}
@@ -456,9 +459,11 @@ impl WasmVM {
456459
}
457460

458461
pub fn sys_sleep(&mut self, millis: u64) -> Result<WasmAsyncResultHandle, WasmFailure> {
462+
let now = now_since_unix_epoch();
459463
use_log_dispatcher!(self, |vm| CoreVM::sys_sleep(
460464
vm,
461-
duration_since_unix_epoch() + Duration::from_millis(millis)
465+
now + Duration::from_millis(millis),
466+
Some(now)
462467
))
463468
.map(Into::into)
464469
.map_err(Into::into)
@@ -477,6 +482,8 @@ impl WasmVM {
477482
service,
478483
handler,
479484
key,
485+
idempotency_key: None,
486+
headers: vec![],
480487
},
481488
buffer.to_vec().into()
482489
))
@@ -498,10 +505,13 @@ impl WasmVM {
498505
service,
499506
handler,
500507
key,
508+
idempotency_key: None,
509+
headers: vec![],
501510
},
502511
buffer.to_vec().into(),
503-
delay.map(|delay| duration_since_unix_epoch() + Duration::from_millis(delay))
512+
delay.map(|delay| now_since_unix_epoch() + Duration::from_millis(delay))
504513
))
514+
.map(|_| ())
505515
.map_err(Into::into)
506516
}
507517

@@ -826,7 +836,7 @@ impl AsyncResultCombinator for AllSettledAsyncResultCombinator {
826836
}
827837
}
828838

829-
fn duration_since_unix_epoch() -> Duration {
839+
fn now_since_unix_epoch() -> Duration {
830840
Duration::from_millis(js_sys::Date::now() as u64)
831841
}
832842

0 commit comments

Comments
 (0)