Split up librqbit http_api and tracing_subscriber into separate features (#188)
* fix lints that were under features * Split up some features and fix desktop * fix github script * fix github script * fix github script * try caching check-desktop
This commit is contained in:
parent
33554159bf
commit
37ee8b70ba
12 changed files with 65 additions and 36 deletions
|
|
@ -3,12 +3,10 @@ use std::{collections::HashSet, marker::PhantomData, net::SocketAddr, str::FromS
|
|||
use anyhow::Context;
|
||||
use buffers::ByteBufOwned;
|
||||
use dht::{DhtStats, Id20};
|
||||
use futures::Stream;
|
||||
use http::StatusCode;
|
||||
use librqbit_core::torrent_metainfo::TorrentMetaV1Info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -20,9 +18,15 @@ use crate::{
|
|||
peer::stats::snapshot::{PeerStatsFilter, PeerStatsSnapshot},
|
||||
FileStream, ManagedTorrentHandle,
|
||||
},
|
||||
tracing_subscriber_config_utils::LineBroadcast,
|
||||
};
|
||||
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
use crate::tracing_subscriber_config_utils::LineBroadcast;
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
use futures::Stream;
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream};
|
||||
|
||||
pub use crate::torrent_state::stats::{LiveStats, TorrentStats};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, ApiError>;
|
||||
|
|
@ -33,6 +37,7 @@ pub type Result<T> = std::result::Result<T, ApiError>;
|
|||
pub struct Api {
|
||||
session: Arc<Session>,
|
||||
rust_log_reload_tx: Option<UnboundedSender<String>>,
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
line_broadcast: Option<LineBroadcast>,
|
||||
}
|
||||
|
||||
|
|
@ -127,11 +132,12 @@ impl Api {
|
|||
pub fn new(
|
||||
session: Arc<Session>,
|
||||
rust_log_reload_tx: Option<UnboundedSender<String>>,
|
||||
line_broadcast: Option<LineBroadcast>,
|
||||
#[cfg(feature = "tracing-subscriber-utils")] line_broadcast: Option<LineBroadcast>,
|
||||
) -> Self {
|
||||
Self {
|
||||
session,
|
||||
rust_log_reload_tx,
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
line_broadcast,
|
||||
}
|
||||
}
|
||||
|
|
@ -258,6 +264,7 @@ impl Api {
|
|||
Ok(Default::default())
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
pub fn api_log_lines_stream(
|
||||
&self,
|
||||
) -> Result<
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(feature = "http-api")]
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use http::StatusCode;
|
||||
use serde::{Serialize, Serializer};
|
||||
|
|
@ -147,6 +148,7 @@ impl std::fmt::Display for ApiError {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "http-api")]
|
||||
impl IntoResponse for ApiError {
|
||||
fn into_response(self) -> Response {
|
||||
let mut response = axum::Json(&self).into_response();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Context;
|
||||
use axum::body::Bytes;
|
||||
use axum::extract::{Path, Query, State};
|
||||
use axum::response::{IntoResponse, Redirect};
|
||||
use axum::response::IntoResponse;
|
||||
use axum::routing::{get, post};
|
||||
use futures::future::BoxFuture;
|
||||
use futures::{FutureExt, TryStreamExt};
|
||||
|
|
@ -459,6 +459,8 @@ impl HttpApi {
|
|||
|
||||
#[cfg(feature = "webui")]
|
||||
{
|
||||
use axum::response::Redirect;
|
||||
|
||||
let webui_router = Router::new()
|
||||
.route(
|
||||
"/",
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ mod create_torrent_file;
|
|||
mod dht_utils;
|
||||
pub mod file_info;
|
||||
mod file_ops;
|
||||
#[cfg(feature = "http-api")]
|
||||
pub mod http_api;
|
||||
#[cfg(feature = "http-api")]
|
||||
pub mod http_api_client;
|
||||
mod merge_streams;
|
||||
mod peer_connection;
|
||||
|
|
@ -44,6 +46,7 @@ mod spawn_utils;
|
|||
pub mod storage;
|
||||
mod stream_connect;
|
||||
mod torrent_state;
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
pub mod tracing_subscriber_config_utils;
|
||||
mod type_aliases;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue