Skip to content

Commit

Permalink
feat(unstable): add metadata to Deno.jupyter.broadcast.
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Sep 27, 2023
1 parent 1c3485f commit 88fea55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/js/40_jupyter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function enableJupyter() {
} = core.ensureFastOps();

globalThis.Deno.jupyter = {
async broadcast(msgType, content) {
await op_jupyter_broadcast(msgType, content);
async broadcast(msgType, content, metadata = {}) {
await op_jupyter_broadcast(msgType, content, metadata);
},
};
}
Expand Down
2 changes: 2 additions & 0 deletions cli/ops/jupyter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub async fn op_jupyter_broadcast(
state: Rc<RefCell<OpState>>,
#[string] message_type: String,
#[serde] content: serde_json::Value,
#[serde] metadata: serde_json::Value,
) -> Result<(), AnyError> {
let (iopub_socket, last_execution_request) = {
let s = state.borrow();
Expand All @@ -52,6 +53,7 @@ pub async fn op_jupyter_broadcast(
last_request
.new_message(&message_type)
.with_content(content)
.with_metadata(metadata)
.send(&mut *iopub_socket.lock().await)
.await?;
}
Expand Down
8 changes: 8 additions & 0 deletions cli/tools/jupyter/jupyter_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ impl JupyterMessage {
self
}

pub(crate) fn with_metadata(
mut self,
metadata: serde_json::Value,
) -> JupyterMessage {
self.metadata = metadata;
self
}

pub(crate) async fn send<S: zeromq::SocketSend>(
&self,
connection: &mut Connection<S>,
Expand Down

0 comments on commit 88fea55

Please sign in to comment.