mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
http: send response sender to request workers
This commit is contained in:
parent
02b9c9d290
commit
f083cac9e0
6 changed files with 78 additions and 221 deletions
|
|
@ -9,6 +9,7 @@ use aquatic_http_protocol::{
|
|||
request::{AnnounceRequest, ScrapeRequest},
|
||||
response::{AnnounceResponse, ScrapeResponse},
|
||||
};
|
||||
use glommio::channels::shared_channel::SharedSender;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct ConsumerId(pub usize);
|
||||
|
|
@ -21,46 +22,15 @@ pub enum ChannelRequest {
|
|||
Announce {
|
||||
request: AnnounceRequest,
|
||||
peer_addr: CanonicalSocketAddr,
|
||||
connection_id: ConnectionId,
|
||||
response_consumer_id: ConsumerId,
|
||||
response_sender: SharedSender<AnnounceResponse>,
|
||||
},
|
||||
Scrape {
|
||||
request: ScrapeRequest,
|
||||
peer_addr: CanonicalSocketAddr,
|
||||
connection_id: ConnectionId,
|
||||
response_consumer_id: ConsumerId,
|
||||
response_sender: SharedSender<ScrapeResponse>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ChannelResponse {
|
||||
Announce {
|
||||
response: AnnounceResponse,
|
||||
peer_addr: CanonicalSocketAddr,
|
||||
connection_id: ConnectionId,
|
||||
},
|
||||
Scrape {
|
||||
response: ScrapeResponse,
|
||||
peer_addr: CanonicalSocketAddr,
|
||||
connection_id: ConnectionId,
|
||||
},
|
||||
}
|
||||
|
||||
impl ChannelResponse {
|
||||
pub fn get_connection_id(&self) -> ConnectionId {
|
||||
match self {
|
||||
Self::Announce { connection_id, .. } => *connection_id,
|
||||
Self::Scrape { connection_id, .. } => *connection_id,
|
||||
}
|
||||
}
|
||||
pub fn get_peer_addr(&self) -> CanonicalSocketAddr {
|
||||
match self {
|
||||
Self::Announce { peer_addr, .. } => *peer_addr,
|
||||
Self::Scrape { peer_addr, .. } => *peer_addr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct State {
|
||||
pub access_list: Arc<AccessListArcSwap>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue