-
Notifications
You must be signed in to change notification settings - Fork 20
feat(capablities)!: sleep & spawn capabilities #1873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gh-worker-dd-mergequeue-cf854d
merged 14 commits into
main
from
jwiriath/runtime-capability
May 11, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a8b1345
feat(capablities): sleep & spawn capabilities
Aaalibaba42 b89ebfc
chore: rename sleeper to capabilites
Aaalibaba42 029bd3f
feat: laziely instantiate the httpclient in native so that it's close…
Aaalibaba42 87094d8
feat: use type of the SpawnCapability directly on Native
Aaalibaba42 895dc46
fix: remove RuntimeSpawner which was effectively a duplicate NativeSp…
Aaalibaba42 c9f97e2
fix: remove spawner
Aaalibaba42 2344176
fix: remove references to spawn capability
Aaalibaba42 e0578e6
revert: we still need tokio dependancy explicit here
Aaalibaba42 28e873e
docs: add comment explaining stuff
Aaalibaba42 a11018b
feat: made tokio_spawn_fn a util function for native tasks instead of…
Aaalibaba42 8d462af
feat: use sleep capability for the fetcher
Aaalibaba42 96420ad
fix: keep runtime locked while spawning workers
Aaalibaba42 b1796a7
chore: fmt
Aaalibaba42 d8094e2
fix: aws-lc-sys and ring were both present
Aaalibaba42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright 2026-Present Datadog, Inc. https://www.datadoghq.com/ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! Native sleep implementation backed by `tokio::time::sleep`. | ||
|
|
||
| use core::future::Future; | ||
| use std::time::Duration; | ||
|
|
||
| use libdd_capabilities::maybe_send::MaybeSend; | ||
| use libdd_capabilities::sleep::SleepCapability; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct NativeSleepCapability; | ||
|
|
||
| impl SleepCapability for NativeSleepCapability { | ||
| fn new() -> Self { | ||
| Self | ||
| } | ||
|
|
||
| fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + MaybeSend { | ||
| tokio::time::sleep(duration) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright 2026-Present Datadog, Inc. https://www.datadoghq.com/ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! Sleep capability trait. | ||
| //! | ||
| //! Abstracts async sleep so that native code can use `tokio::time::sleep` | ||
| //! while wasm delegates to `setTimeout` via `JsFuture`. | ||
|
|
||
| use crate::maybe_send::MaybeSend; | ||
| use core::future::Future; | ||
| use std::time::Duration; | ||
|
|
||
| pub trait SleepCapability: Clone + std::fmt::Debug { | ||
| /// Construct a new sleeper. | ||
| /// | ||
| /// Stateless impls return a unit struct; stateful impls (mock clocks, | ||
| /// virtual time sources, etc.) should return a sensible default. Callers | ||
| /// that don't have an instance handy can use the static-style | ||
| /// `C::new().sleep(duration)` pattern, mirroring `HttpClientCapability`'s | ||
| /// `new_client()` + `request(&self)` shape. | ||
| fn new() -> Self; | ||
|
|
||
| fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + MaybeSend; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.