Skip to content
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

feat(jupyter): send Jupyter messaging metadata with Deno.jupyter.broadcast #20714

Merged
merged 4 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions cli/tsc/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,9 @@ declare namespace Deno {
export function broadcast(
msgType: string,
content: Record<string, unknown>,
extra?: {
metadata?: Record<string, unknown>;
},
): Promise<void>;
}
}
Expand Down