-
Notifications
You must be signed in to change notification settings - Fork 0
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
[TS-2073] Server implementation for tooling interop #11
base: develop
Are you sure you want to change the base?
Conversation
Introduce foundational JSON-RPC types, deserialization, and an initial swing at a POC method API for the project and package.
use std::sync::RwLock; | ||
use std::{io, thread}; | ||
|
||
use self::proto::{Message, Request, Response}; |
Check warning
Code scanning / clippy
unused import: Request Warning
loop { | ||
// Block the main thread until we have an input line available to be read. | ||
// This is ok because, in theory, tasks will be processed on background threads. | ||
if let Err(e) = stdin.read_line(&mut line) { |
Check warning
Code scanning / clippy
unused variable: e Warning
} | ||
|
||
/// Route and execute the request, returning the result. | ||
async fn route(line: &str, tx: Sender<Result<Response, Error>>) -> Result<Response, Error> { |
Check warning
Code scanning / clippy
unused variable: tx Warning
|
||
/// Route and execute the request, returning the result. | ||
async fn route(line: &str, tx: Sender<Result<Response, Error>>) -> Result<Response, Error> { | ||
let req = Message::from_json(line); |
Check warning
Code scanning / clippy
unused variable: req Warning
_ => panic!(), | ||
}; | ||
|
||
Ok(()) |
Check warning
Code scanning / clippy
unreachable expression Warning
match request.method { | ||
Method::Package(PackageMethod::IsCached) => panic!(), | ||
_ => panic!(), | ||
}; |
Check warning
Code scanning / clippy
unreachable expression Warning
} | ||
|
||
impl PackageMethod { | ||
pub fn from_value(method: &str, value: serde_json::Value) -> Result<Self, Error> { |
Check warning
Code scanning / clippy
unused variable: value Warning
Ok(()) | ||
} | ||
|
||
fn route_project(method: ProjectMethod, tx: Sender<Result<Response, Error>>) { |
Check warning
Code scanning / clippy
unused variable: tx Warning
} | ||
} | ||
|
||
fn respond_msg(rx: Receiver<Result<Response, Error>>, cancel: RwLock<bool>) { |
Check warning
Code scanning / clippy
unused variable: cancel Warning
|
||
/// Wrapper error types and codes. | ||
#[error("${0:?}")] | ||
ProjectError(String) = 1000, |
Check warning
Code scanning / clippy
variant name ends with the enum's name Warning
ProjectError(String) = 1000, | ||
|
||
#[error("{0:?}")] | ||
PackageError(String) = 2000, |
Check warning
Code scanning / clippy
variant name ends with the enum's name Warning
let mut stdout = io::stdout(); | ||
while let Ok(res) = rx.recv() { | ||
let msg = res.map(|x| serde_json::to_string(&x).unwrap()); | ||
stdout.write_all(msg.unwrap().as_bytes()); |
Check warning
Code scanning / clippy
unused std::result::Result that must be used Warning
while let Ok(res) = rx.recv() { | ||
let msg = res.map(|x| serde_json::to_string(&x).unwrap()); | ||
stdout.write_all(msg.unwrap().as_bytes()); | ||
stdout.write_all("\n".as_bytes()); |
Check warning
Code scanning / clippy
unused std::result::Result that must be used Warning
[TS-2073] Implement primitive file-based project lock
|
||
/// Only one server process can "own" a project at a single time. | ||
/// We enforce this exclusive access through the creation and deletion of this lockfile. | ||
const LOCKFILE: &'static str = ".server-lock"; |
Check warning
Code scanning / clippy
constants have by default a 'static lifetime Warning
No description provided.