Unify service version, postcard, remove error overhead
This commit is contained in:
@@ -6,10 +6,20 @@ pub mod test;
|
||||
|
||||
use ::err::Error;
|
||||
use futures_util::TryFutureExt;
|
||||
use netpod::{Cluster, NodeConfig, NodeConfigCached, ProxyConfig};
|
||||
use netpod::Cluster;
|
||||
use netpod::NodeConfig;
|
||||
use netpod::NodeConfigCached;
|
||||
use netpod::ProxyConfig;
|
||||
use netpod::ServiceVersion;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
pub fn spawn_test_hosts(cluster: Cluster) -> Vec<JoinHandle<Result<(), Error>>> {
|
||||
let service_version = ServiceVersion {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
pre: None,
|
||||
};
|
||||
let mut ret = Vec::new();
|
||||
for node in &cluster.nodes {
|
||||
let node_config = NodeConfig {
|
||||
@@ -18,7 +28,7 @@ pub fn spawn_test_hosts(cluster: Cluster) -> Vec<JoinHandle<Result<(), Error>>>
|
||||
};
|
||||
let node_config: Result<NodeConfigCached, Error> = node_config.into();
|
||||
let node_config = node_config.unwrap();
|
||||
let h = tokio::spawn(httpret::host(node_config).map_err(Error::from));
|
||||
let h = tokio::spawn(httpret::host(node_config, service_version.clone()).map_err(Error::from));
|
||||
ret.push(h);
|
||||
}
|
||||
|
||||
@@ -27,12 +37,12 @@ pub fn spawn_test_hosts(cluster: Cluster) -> Vec<JoinHandle<Result<(), Error>>>
|
||||
ret
|
||||
}
|
||||
|
||||
pub async fn run_node(node_config: NodeConfigCached) -> Result<(), Error> {
|
||||
httpret::host(node_config).await?;
|
||||
pub async fn run_node(node_config: NodeConfigCached, service_version: ServiceVersion) -> Result<(), Error> {
|
||||
httpret::host(node_config, service_version).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run_proxy(proxy_config: ProxyConfig) -> Result<(), Error> {
|
||||
httpret::proxy::proxy(proxy_config).await?;
|
||||
pub async fn run_proxy(proxy_config: ProxyConfig, service_version: ServiceVersion) -> Result<(), Error> {
|
||||
httpret::proxy::proxy(proxy_config, service_version).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ async fn get_json_common(
|
||||
if expect_finalised_range {
|
||||
if !res
|
||||
.get("rangeFinal")
|
||||
.ok_or(Error::with_msg("missing rangeFinal"))?
|
||||
.ok_or_else(|| Error::with_msg("missing rangeFinal"))?
|
||||
.as_bool()
|
||||
.ok_or(Error::with_msg("key rangeFinal not bool"))?
|
||||
.ok_or_else(|| Error::with_msg("key rangeFinal not bool"))?
|
||||
{
|
||||
return Err(Error::with_msg("expected rangeFinal"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user