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
darosior committed Jan 20, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
darosior Antoine Poinsot
1 parent 767c38e commit 96ffca4
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -12,10 +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"
required-features = ["jsonrpc_server"]

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

[dependencies]
revault_tx = { git = "https://github.com/revault/revault_tx", features = ["use-serde"] }
@@ -54,6 +60,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
@@ -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;
@@ -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)
@@ -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");

0 comments on commit 96ffca4

Please sign in to comment.