mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
cli: start to extract a generic rpc interface (#171299)
I want to use the rpc interface for communication via stdin/out in wsl, but currently RPC is tightly coupled to the control server. The control server also speaks msgpack instead of JSON, since it deals with binary messages. WSL won't, and we'll want to use JSON to interact with VS Code, so some separation is needed. This pulls out a base set of RPC types for use in both scenarios. Currently these are only 'helper' structs that don't actually do any i/o, but once I figure out the model I would like to have a cleaner way to do i/o in a unified way as well. For the control server, previously we basically handled all methods in one big `switch` block with nasty macros, whereas now there's nicer `register_a/sync` functions. Some additional small refactors were needed to preserve the strict ordering of server messages, since they need to be order else we get decompression errors. This is the `start_bridge_write_loop`. As a small benefit, this means we can avoid the relatively expensive async Tokio mutex that we were using, and instead use the standard library mutex.
This commit is contained in:
@@ -105,7 +105,7 @@ pub fn new_rpc_prefix() -> String {
|
||||
// Base logger implementation
|
||||
#[derive(Clone)]
|
||||
pub struct Logger {
|
||||
tracer: Tracer,
|
||||
tracer: Arc<Tracer>,
|
||||
sink: Vec<Box<dyn LogSink>>,
|
||||
prefix: Option<String>,
|
||||
}
|
||||
@@ -188,7 +188,7 @@ impl LogSink for FileLogSink {
|
||||
impl Logger {
|
||||
pub fn test() -> Self {
|
||||
Self {
|
||||
tracer: TracerProvider::builder().build().tracer("codeclitest"),
|
||||
tracer: Arc::new(TracerProvider::builder().build().tracer("codeclitest")),
|
||||
sink: vec![],
|
||||
prefix: None,
|
||||
}
|
||||
@@ -196,7 +196,7 @@ impl Logger {
|
||||
|
||||
pub fn new(tracer: Tracer, level: Level) -> Self {
|
||||
Self {
|
||||
tracer,
|
||||
tracer: Arc::new(tracer),
|
||||
sink: vec![Box::new(StdioLogSink { level })],
|
||||
prefix: None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user