Skip to main content

Crate forge_protocol_client

Crate forge_protocol_client 

Source
Expand description

The protocol client: the instrument that speaks the socket from the other side of it.

It is what curl cannot be for a socket. It connects to a running forge, sends a script of messages as a client would, and prints everything the server says back as one line of JSON each - so a person debugging a client has both halves of the conversation in front of them rather than a guess about which end is wrong.

forge-protocol-client --url ws://127.0.0.1:8790/socket --script ./walk.txt

A script is the protocol in miniature rather than a vocabulary of its own: a verb and its arguments, and raw JSON where a message carries a payload.

# a comment
subscribe home
subscribe session Busytools/forge/lead
more Busytools/forge/lead 10
commit_diff Busytools/forge/lead 4f6870839
file_content Busytools/forge/lead crates/forge-server/src/lib.rs
file_content Busytools/forge/lead crates/forge-server/src/lib.rs 4f6870839
command {"prompt": {"key": {"org": "Busytools", "project": "forge", "label": "lead"}, "text": "hello", "attachments": []}}
ask {"submit_review": {"project": "forge", "branch": "main", "summary": null, "thread_ids": [], "origin": {"org": "Busytools", "project": "forge", "label": "lead"}}}

ask is command with a reply asked for, so the awaited Reply path is exercised rather than only the fire-and-forget one.

Re-exportsยง

pub(crate) use std::path::PathBuf; ๐Ÿ”’
pub(crate) use std::time::Duration; ๐Ÿ”’
pub(crate) use clap::Parser; ๐Ÿ”’
pub(crate) use forge_primitives::SessionSlot; ๐Ÿ”’
pub(crate) use forge_server::Command; ๐Ÿ”’
pub(crate) use ClientMessage; ๐Ÿ”’
pub(crate) use Subject; ๐Ÿ”’
pub(crate) use SinkExt; ๐Ÿ”’
pub(crate) use StreamExt; ๐Ÿ”’
pub(crate) use tokio_tungstenite::tungstenite::Message; ๐Ÿ”’

Structsยง

Args ๐Ÿ”’

Functionsยง

main ๐Ÿ”’
next_within ๐Ÿ”’
The socketโ€™s next message, or None once it stops arriving.
parse_line ๐Ÿ”’
One script line as a message to send.
subject ๐Ÿ”’
home, board, usage, dictate_models, extensions, or session <org>/<project>/<label>.