Skip to content

Commit

Permalink
Make the jsonrpc module optional through a default feature
Browse files Browse the repository at this point in the history
  • Loading branch information
darosior committed Jan 19, 2022
1 parent a70b040 commit 9c33683
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ jobs:
toolchain: ${{ matrix.toolchain }}
override: true
profile: minimal
- name: Test on Rust ${{ matrix.toolchain }}
- name: Test on Rust ${{ matrix.toolchain }} (only Windows)
if: matrix.os == 'windows-latest'
run: cargo test --verbose --no-default-features
- name: Test on Rust ${{ matrix.toolchain }} (non Windows)
if: matrix.os == 'windows-latest'
run: cargo test --verbose --color always -- --nocapture
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ exclude = [".github/", ".cirrus.yml", "tests/", "test_data/", "contrib/", "pypr
[[bin]]
name = "revaultd"
path = "src/bin/daemon.rs"
required-features = ["jsonrpc_server"]

[[bin]]
name = "revault-cli"
path = "src/bin/cli.rs"

[features]
default = ["jsonrpc_server"]
jsonrpc_server = ["jsonrpc-core", "jsonrpc-derive", "mio"]

[dependencies]
revault_tx = { git = "https://github.com/revault/revault_tx", features = ["use-serde"] }
revault_net = { git = "https://github.com/revault/revault_net" }
Expand Down Expand Up @@ -54,6 +59,6 @@ rusqlite = { version = "0.26.3", features = ["bundled", "unlock_notify"] }
libc = "0.2.80"

# For the JSONRPC server
jsonrpc-core = "15.1"
jsonrpc-derive = "15.1"
mio = { version = "0.7", features = ["default", "os-poll", "os-util", "uds"] }
jsonrpc-core = { version = "15.1", optional = true }
jsonrpc-derive = { version = "15.1", optional = true }
mio = { version = "0.7", features = ["default", "os-poll", "os-util", "uds"], optional = true }
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod commands;
mod communication;
pub mod config;
mod database;
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "jsonrpc_server"))]
mod jsonrpc;
mod revaultd;
mod sigfetcher;
Expand Down Expand Up @@ -146,8 +146,8 @@ impl DaemonControl {
self.sigfetcher_conn.shutdown();
}

// TODO: make it optional at compile time
/// Start and bind the server to the configured UNIX socket
#[cfg(all(not(windows), feature = "jsonrpc_server"))]
pub fn rpc_server_setup(&self) -> Result<jsonrpc::server::UnixListener, io::Error> {
let socket_file = self.revaultd.read().unwrap().rpc_socket_file();
jsonrpc::server::rpcserver_setup(socket_file)
Expand Down Expand Up @@ -260,8 +260,8 @@ impl DaemonHandle {
.expect("Joining sigfetcher thread");
}

// TODO: make it optional at compilation time
/// Start the JSONRPC server and listen for commands until we are stopped
#[cfg(all(not(windows), feature = "jsonrpc_server"))]
pub fn rpc_server(&self) -> Result<(), io::Error> {
log::info!("Starting JSONRPC server");

Expand Down

0 comments on commit 9c33683

Please sign in to comment.