Skip to content

Commit

Permalink
chore: update rust crate deno_core to 0.110.0 (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Dec 7, 2021
1 parent a39b17d commit df5a7bc
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 87 deletions.
125 changes: 100 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion harmonizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/lib.rs"

[dependencies]
apollo-federation-types = "0.1"
deno_core = "0.86.0"
deno_core = "0.110.0"
serde_json = "1"

[dependencies.serde]
Expand Down
36 changes: 9 additions & 27 deletions harmonizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,9 @@ pub fn harmonize(
// We'll use this channel to get the results
let (tx, rx) = channel();

// The first thing we do is define an op so we can print data to STDOUT,
// because by default the JavaScript console functions are just stubs (they
// don't do anything).

// Register the op for outputting bytes to stdout. It can be invoked with
// Deno.core.dispatch and the id this method returns or
// Deno.core.dispatchByName and the name provided.
runtime.register_op(
"op_print",
// The op_fn callback takes a state object OpState,
// a structured arg of type `T` and an optional ZeroCopyBuf,
// a mutable reference to a JavaScript ArrayBuffer
op_sync(|_state, maybe_msg: Option<String>, _zero_copy| {
if let Some(msg) = maybe_msg {
println!("{}", msg);
}
Ok(()) // No meaningful result
}),
);

runtime.register_op(
"op_composition_result",
op_sync(move |_state, value, _zero_copy| {
op_sync(move |_state, value, _zero_copy: ()| {
let js_composition_result: Result<String, Vec<CompositionError>> =
serde_json::from_value(value)
.expect("could not deserialize composition result from JS.");
Expand All @@ -90,10 +70,12 @@ pub fn harmonize(
}),
);

runtime.sync_ops_cache();

// The runtime automatically contains a Deno.core object with several
// functions for interacting with it.
runtime
.execute(
.execute_script(
"<init>",
r#"
// First we initialize the ops cache.
Expand Down Expand Up @@ -132,16 +114,16 @@ exports = {};

// Load URL polyfill
runtime
.execute("url_shim.js", include_str!("../dist/url_shim.js"))
.execute_script("url_shim.js", include_str!("../dist/url_shim.js"))
.expect("unable to evaluate url_shim module");

runtime
.execute("<url_shim_assignment>", "whatwg_url_1 = url_shim;")
.execute_script("<url_shim_assignment>", "whatwg_url_1 = url_shim;")
.expect("unable to assign url_shim");

// Load the composition library.
runtime
.execute("composition.js", include_str!("../dist/composition.js"))
.execute_script("composition.js", include_str!("../dist/composition.js"))
.expect("unable to evaluate composition module");

// We literally just turn it into a JSON object that we'll execute within
Expand All @@ -153,11 +135,11 @@ exports = {};
);

runtime
.execute("<set_service_list>", &service_list_javascript)
.execute_script("<set_service_list>", &service_list_javascript)
.expect("unable to evaluate service list in JavaScript runtime");

runtime
.execute("do_compose.js", include_str!("../js/do_compose.js"))
.execute_script("do_compose.js", include_str!("../js/do_compose.js"))
.expect("unable to invoke composition in JavaScript runtime");

rx.recv().expect("channel remains open")
Expand Down
2 changes: 1 addition & 1 deletion router-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include = ["js-dist/**/*", "bundled/**/*", "src/**/*", "Cargo.toml"]

[dependencies]
anyhow = "1.0.44"
deno_core = "0.86.0"
deno_core = "0.110.0"
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.68"
thiserror = "1.0.29"
Expand Down

0 comments on commit df5a7bc

Please sign in to comment.