-
Notifications
You must be signed in to change notification settings - Fork 664
Add V8Runtime skeleton + HostType::Js
#2923
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,96 @@ | ||
| use crate::{ | ||
| db::datastore::locking_tx_datastore::MutTxId, | ||
| host::{ | ||
| module_host::{DynModule, Module, ModuleInfo, ModuleInstance, ModuleRuntime}, | ||
| Scheduler, | ||
| }, | ||
| module_host_context::ModuleCreationContext, | ||
| replica_context::ReplicaContext, | ||
| }; | ||
| use anyhow::anyhow; | ||
| use std::sync::{Arc, LazyLock}; | ||
|
|
||
| use super::module_host::CallReducerParams; | ||
|
|
||
| /// The V8 runtime, for modules written in e.g., JS or TypeScript. | ||
| #[derive(Default)] | ||
| pub struct V8Runtime { | ||
| _priv: (), | ||
| } | ||
|
|
||
| impl ModuleRuntime for V8Runtime { | ||
| fn make_actor(&self, mcc: ModuleCreationContext<'_>) -> anyhow::Result<impl Module> { | ||
| V8_RUNTIME_GLOBAL.make_actor(mcc) | ||
| } | ||
| } | ||
|
|
||
| static V8_RUNTIME_GLOBAL: LazyLock<V8RuntimeInner> = LazyLock::new(V8RuntimeInner::new); | ||
|
|
||
| /// The actual V8 runtime, with initialization of V8. | ||
| struct V8RuntimeInner { | ||
| _priv: (), | ||
| } | ||
|
|
||
| impl V8RuntimeInner { | ||
| #[allow(clippy::new_without_default)] | ||
| const fn new() -> Self { | ||
| // TODO: actually setup V8. | ||
|
|
||
| Self { _priv: () } | ||
| } | ||
|
|
||
| fn make_actor(&self, _: ModuleCreationContext<'_>) -> anyhow::Result<impl Module> { | ||
| Err::<JsModule, _>(anyhow!("v8_todo")) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone)] | ||
| struct JsModule; | ||
|
|
||
| impl DynModule for JsModule { | ||
| fn replica_ctx(&self) -> &Arc<ReplicaContext> { | ||
| todo!() | ||
| } | ||
|
|
||
| fn scheduler(&self) -> &Scheduler { | ||
| todo!() | ||
| } | ||
| } | ||
|
|
||
| impl Module for JsModule { | ||
| type Instance = JsInstance; | ||
|
|
||
| type InitialInstances<'a> = std::iter::Empty<JsInstance>; | ||
|
|
||
| fn initial_instances(&mut self) -> Self::InitialInstances<'_> { | ||
| std::iter::empty() | ||
| } | ||
|
|
||
| fn info(&self) -> Arc<ModuleInfo> { | ||
| todo!() | ||
| } | ||
|
|
||
| fn create_instance(&self) -> Self::Instance { | ||
| todo!() | ||
| } | ||
| } | ||
|
|
||
| struct JsInstance; | ||
|
|
||
| impl ModuleInstance for JsInstance { | ||
| fn trapped(&self) -> bool { | ||
| todo!() | ||
| } | ||
|
|
||
| fn update_database( | ||
| &mut self, | ||
| _program: crate::db::datastore::traits::Program, | ||
| _old_module_info: Arc<ModuleInfo>, | ||
| ) -> anyhow::Result<super::UpdateDatabaseResult> { | ||
| todo!() | ||
| } | ||
|
|
||
| fn call_reducer(&mut self, _tx: Option<MutTxId>, _params: CallReducerParams) -> super::ReducerCallResult { | ||
| todo!() | ||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -74,4 +74,5 @@ pub struct NodeStatus { | |
| #[repr(i32)] | ||
| pub enum HostType { | ||
| Wasm = 0, | ||
| Js, | ||
| } | ||
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
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.