#node #applications #service #operating #management #safenode #rpc

sn_service_management

一个用于将safenode作为服务安装、管理和运行的命令行应用程序

26个版本

0.3.9 2024年7月29日
0.3.8 2024年7月8日
0.3.7 2024年6月13日
0.3.0 2024年5月24日
0.1.2 2024年3月21日

#3#operating

Download history 362/week @ 2024-04-20 221/week @ 2024-04-27 494/week @ 2024-05-04 454/week @ 2024-05-11 594/week @ 2024-05-18 424/week @ 2024-05-25 1149/week @ 2024-06-01 726/week @ 2024-06-08 313/week @ 2024-06-15 338/week @ 2024-06-22 356/week @ 2024-06-29 366/week @ 2024-07-06 242/week @ 2024-07-13 231/week @ 2024-07-20 423/week @ 2024-07-27 205/week @ 2024-08-03

1,135 每月下载量
4 crates 中使用

GPL-3.0 许可证

415KB
7.5K SLoC

服务管理

提供处理服务的实用工具,这些工具主要用于节点管理器。

RPC操作

RpcActions trait定义了与safenode交互的当前协议

node_info: Returns information about the node, such as its peer ID and version.
network_info: Retrieves network-related information, such as the peers currently connected to the node.
record_addresses: Provides a list of the node's record addresses.
restart_node: Requests the node to restart.
stop_node: Requests the node to stop its operations.
update_node: Updates the node with provided parameters.

crate的使用者可以针对trait编程,而不是针对RpcClient实现。

这可以方便进行基于行为的功能测试,例如

use mockall::mock;
use mockall::predicate::*;

mock! {
    pub RpcClient {}
    #[async_trait]
    impl RpcClientInterface for RpcClient {
        async fn node_info(&self) -> RpcResult<NodeInfo>;
        async fn network_info(&self) -> RpcResult<NetworkInfo>;
        async fn record_addresses(&self) -> Result<Vec<RecordAddress>>;
        async fn gossipsub_subscribe(&self, topic: &str) -> Result<()>;
        async fn gossipsub_unsubscribe(&self, topic: &str) -> Result<()>;
        async fn gossipsub_publish(&self, topic: &str, message: &str) -> Result<()>;
        async fn node_restart(&self, delay_millis: u64) -> Result<()>;
        async fn node_stop(&self, delay_millis: u64) -> Result<()>;
        async fn node_update(&self, delay_millis: u64) -> Result<()>;
    }
}

依赖项

~37–71MB
~1.5M SLoC