mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
offchain: Upgrade hyper to 0.13, which uses tokio 0.2 (#4860)
* service: Don't depend on tokio-executor Seems to be a leftover dependency that's not used anymore. * offchain: Upgrade hyper to 0.13, which uses tokio 0.2 * offchain: Adapt HTTP tests to Tokio 0.2 * network: Don't transitively include tokio 0.2 in WASM 1) We don't specifically depend on Tokio codec impls 2) Conflating features in Cargo means that enabling Tokio runtime in the native environment will also do so in WASM, where it's obviously not implemented and causes a compilation error. * grafana-data-source: Pull hyper/tokio only in native environment
This commit is contained in:
@@ -8,8 +8,6 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.8"
|
||||
hyper = { version = "0.13.1", default-features = false, features = ["stream"] }
|
||||
tokio = "0.2"
|
||||
futures-util = { version = "0.3.1", default-features = false, features = ["io"] }
|
||||
serde_json = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
@@ -21,3 +19,5 @@ derive_more = "0.99"
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
async-std = { version = "1.0.1", features = ["unstable"] }
|
||||
hyper = { version = "0.13.1", default-features = false, features = ["stream"] }
|
||||
tokio = "0.2"
|
||||
|
||||
@@ -72,11 +72,13 @@ pub fn record_metrics_slice(metrics: &[(&str, f32)]) -> Result<(), Error> {
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
pub enum Error {
|
||||
/// Hyper internal error.
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
Hyper(hyper::Error),
|
||||
/// Http request error.
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
Http(hyper::http::Error),
|
||||
/// Serialization/deserialization error.
|
||||
Serde(serde_json::Error),
|
||||
/// Http request error.
|
||||
Http(hyper::http::Error),
|
||||
/// Timestamp error.
|
||||
Timestamp(TryFromIntError),
|
||||
/// i/o error.
|
||||
@@ -86,9 +88,11 @@ pub enum Error {
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
Error::Hyper(error) => Some(error),
|
||||
Error::Serde(error) => Some(error),
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
Error::Http(error) => Some(error),
|
||||
Error::Serde(error) => Some(error),
|
||||
Error::Timestamp(error) => Some(error),
|
||||
Error::Io(error) => Some(error)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,15 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
use hyper::{Body, Request, Response, header, service::{service_fn, make_service_fn}, Server};
|
||||
use chrono::{Duration, Utc};
|
||||
use futures_util::{FutureExt, TryStreamExt, future::{Future, select, Either}};
|
||||
use futures_timer::Delay;
|
||||
use crate::{DATABASE, Error, types::{Target, Query, TimeseriesData, Range}};
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
use hyper::{Body, Request, Response, header, service::{service_fn, make_service_fn}, Server};
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
async fn api_response(req: Request<Body>) -> Result<Response<Body>, Error> {
|
||||
match req.uri().path() {
|
||||
"/search" => {
|
||||
@@ -57,6 +60,7 @@ async fn api_response(req: Request<Body>) -> Result<Response<Body>, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
async fn map_request_to_response<Req, Res, T>(req: Request<Body>, transformation: T) -> Result<Response<Body>, Error>
|
||||
where
|
||||
Req: DeserializeOwned,
|
||||
|
||||
Reference in New Issue
Block a user