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

[TS-2073] Server implementation for tooling interop #11

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

ethangreen-dev
Copy link
Member

No description provided.

Introduce foundational JSON-RPC types, deserialization,
and an initial swing at a POC method API for the project
and package.
src/server/mod.rs Fixed Show fixed Hide fixed
use std::sync::RwLock;
use std::{io, thread};

use self::proto::{Message, Request, Response};

Check warning

Code scanning / clippy

unused import: Request Warning

unused import: Request
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

unused variable: e
}

/// 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

unused variable: tx

/// 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

unused variable: req
_ => panic!(),
};

Ok(())

Check warning

Code scanning / clippy

unreachable expression Warning

unreachable expression
Comment on lines +12 to +15
match request.method {
Method::Package(PackageMethod::IsCached) => panic!(),
_ => panic!(),
};

Check warning

Code scanning / clippy

unreachable expression Warning

unreachable expression
}

impl PackageMethod {
pub fn from_value(method: &str, value: serde_json::Value) -> Result<Self, Error> {

Check warning

Code scanning / clippy

unused variable: value Warning

unused variable: value
Ok(())
}

fn route_project(method: ProjectMethod, tx: Sender<Result<Response, Error>>) {

Check warning

Code scanning / clippy

unused variable: tx Warning

unused variable: tx
}
}

fn respond_msg(rx: Receiver<Result<Response, Error>>, cancel: RwLock<bool>) {

Check warning

Code scanning / clippy

unused variable: cancel Warning

unused variable: cancel
src/server/mod.rs Fixed Show fixed Hide fixed

/// Wrapper error types and codes.
#[error("${0:?}")]
ProjectError(String) = 1000,

Check warning

Code scanning / clippy

variant name ends with the enum's name Warning

variant name ends with the enum's name
ProjectError(String) = 1000,

#[error("{0:?}")]
PackageError(String) = 2000,

Check warning

Code scanning / clippy

variant name ends with the enum's name Warning

variant name ends with the enum's name
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

unused std::result::Result that must be used
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

unused std::result::Result that must be used

/// 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

constants have by default a 'static lifetime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant