-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage-provider): Added a storage provider CLI component with d…
…efined barebones and commands
- Loading branch information
1 parent
ff1797b
commit 3d4c76b
Showing
10 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "polka-storage-provider" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
license-file.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
cli-primitives = { path = "../../primitives/cli" } | ||
clap = { workspace = true, features = ["derive"] } | ||
url = { workspace = true } | ||
env_logger = { workspace = true } | ||
tokio = { workspace = true, features = ["full"] } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::commands::{RunRpcCmd, StopRpcCmd}; | ||
use clap::Parser; | ||
|
||
/// A CLI application that facilitates management operations over a running full node and other components. | ||
#[derive(Parser, Debug, Clone)] | ||
#[command(author, version, about, long_about = None)] | ||
pub(crate) struct Cli { | ||
#[command(subcommand)] | ||
pub subcommand: Option<Subcommand>, | ||
} | ||
|
||
/// Supported sub-commands. | ||
#[derive(Debug, clap::Subcommand, Clone)] | ||
pub enum Subcommand { | ||
/// Command to run the RPC server. | ||
RunRpc(RunRpcCmd), | ||
/// Command to stop the RPC server. | ||
StopRpc(StopRpcCmd), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod run_rpc_cmd; | ||
mod stop_rpc_cmd; | ||
|
||
pub(crate) mod runner; | ||
|
||
pub(crate) use run_rpc_cmd::RunRpcCmd; | ||
pub(crate) use stop_rpc_cmd::StopRpcCmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use clap::Parser; | ||
use url::Url; | ||
|
||
/// The `run-rpc` command used to run a server to listen for RPC calls. | ||
#[derive(Debug, Clone, Parser)] | ||
pub(crate) struct RunRpcCmd { | ||
/// RPC API endpoint of the parachain node. | ||
#[arg(short = 'n', long, default_value = "ws://127.0.0.1:9944")] | ||
pub node_rpc_address: Url, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::cli::Subcommand; | ||
use crate::Cli; | ||
use clap::Parser; | ||
use cli_primitives::Result; | ||
|
||
/// Parses command line arguments into the service configuration and runs the specified | ||
/// command with it. | ||
pub(crate) async fn run() -> Result<()> { | ||
// CLI arguments parsed and mapped to the struct. | ||
let cli_arguments: Cli = Cli::parse(); | ||
|
||
match &cli_arguments.subcommand { | ||
Some(Subcommand::RunRpc(_cmd)) => { | ||
// TODO(@serhii, #52, 2024-05-28): Implement an RPC server to listen for RPC calls, which will be used by the UI app to display information to the user. | ||
Ok(()) | ||
} | ||
Some(Subcommand::StopRpc(_cmd)) => { | ||
// TODO(@serhii, #52, 2024-05-28): Implement functionality to gracefully stop the previously started RPC server. | ||
Ok(()) | ||
} | ||
None => { | ||
// TODO(@serhii, #54, 2024-05-28): Add default logic for when no specific command is requested. | ||
Ok(()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use clap::Parser; | ||
|
||
/// The `stop-rpc` command used to stop a server that listen for RPC calls. | ||
#[derive(Debug, Clone, Parser)] | ||
pub(crate) struct StopRpcCmd {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! A CLI application that facilitates management operations over a running full node and other components. | ||
#![deny(unused_crate_dependencies)] | ||
|
||
mod cli; | ||
|
||
pub(crate) mod commands; | ||
pub(crate) use cli::Cli; | ||
|
||
use cli_primitives::Result; | ||
use commands::runner; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Logger initialization. | ||
env_logger::init(); | ||
|
||
// Run requested command. | ||
runner::run().await | ||
} |