Free up name ThinClientService
This commit is contained in:
parent
ca80bc33c6
commit
cd96843699
|
@ -12,22 +12,22 @@ use std::io::sink;
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
use streamer;
|
||||
use thin_client_service::ThinClientService;
|
||||
use thin_client_service::RequestProcessor;
|
||||
|
||||
pub struct EntryWriter<'a> {
|
||||
accounting_stage: &'a AccountingStage,
|
||||
thin_client_service: &'a ThinClientService,
|
||||
request_processor: &'a RequestProcessor,
|
||||
}
|
||||
|
||||
impl<'a> EntryWriter<'a> {
|
||||
/// Create a new Tpu that wraps the given Accountant.
|
||||
pub fn new(
|
||||
accounting_stage: &'a AccountingStage,
|
||||
thin_client_service: &'a ThinClientService,
|
||||
request_processor: &'a RequestProcessor,
|
||||
) -> Self {
|
||||
EntryWriter {
|
||||
accounting_stage,
|
||||
thin_client_service,
|
||||
request_processor,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,7 @@ impl<'a> EntryWriter<'a> {
|
|||
"{}",
|
||||
serde_json::to_string(&entry).expect("'entry' to_strong in fn write_entry")
|
||||
).expect("writeln! in fn write_entry");
|
||||
self.thin_client_service
|
||||
.notify_entry_info_subscribers(&entry);
|
||||
self.request_processor.notify_entry_info_subscribers(&entry);
|
||||
}
|
||||
|
||||
fn write_entries<W: Write>(&self, writer: &Mutex<W>) -> Result<Vec<Entry>> {
|
||||
|
|
|
@ -62,18 +62,18 @@ pub enum Response {
|
|||
EntryInfo(EntryInfo),
|
||||
}
|
||||
|
||||
pub struct ThinClientService {
|
||||
pub struct RequestProcessor {
|
||||
//pub output: Mutex<Receiver<Response>>,
|
||||
//response_sender: Mutex<Sender<Response>>,
|
||||
accountant: Arc<Accountant>,
|
||||
entry_info_subscribers: Mutex<Vec<SocketAddr>>,
|
||||
}
|
||||
|
||||
impl ThinClientService {
|
||||
impl RequestProcessor {
|
||||
/// Create a new Tpu that wraps the given Accountant.
|
||||
pub fn new(accountant: Arc<Accountant>) -> Self {
|
||||
//let (response_sender, output) = channel();
|
||||
ThinClientService {
|
||||
RequestProcessor {
|
||||
//output: Mutex::new(output),
|
||||
//response_sender: Mutex::new(response_sender),
|
||||
accountant,
|
||||
|
|
14
src/tpu.rs
14
src/tpu.rs
|
@ -17,11 +17,11 @@ use std::sync::{Arc, Mutex, RwLock};
|
|||
use std::thread::{spawn, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use streamer;
|
||||
use thin_client_service::ThinClientService;
|
||||
use thin_client_service::RequestProcessor;
|
||||
|
||||
pub struct Tpu {
|
||||
accounting_stage: AccountingStage,
|
||||
thin_client_service: ThinClientService,
|
||||
request_processor: RequestProcessor,
|
||||
}
|
||||
|
||||
type SharedTpu = Arc<Tpu>;
|
||||
|
@ -29,10 +29,10 @@ type SharedTpu = Arc<Tpu>;
|
|||
impl Tpu {
|
||||
/// Create a new Tpu that wraps the given Accountant.
|
||||
pub fn new(accounting_stage: AccountingStage) -> Self {
|
||||
let thin_client_service = ThinClientService::new(accounting_stage.accountant.clone());
|
||||
let request_processor = RequestProcessor::new(accounting_stage.accountant.clone());
|
||||
Tpu {
|
||||
accounting_stage,
|
||||
thin_client_service,
|
||||
request_processor,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ impl Tpu {
|
|||
writer: Mutex<W>,
|
||||
) -> JoinHandle<()> {
|
||||
spawn(move || loop {
|
||||
let entry_writer = EntryWriter::new(&obj.accounting_stage, &obj.thin_client_service);
|
||||
let entry_writer = EntryWriter::new(&obj.accounting_stage, &obj.request_processor);
|
||||
let _ = entry_writer.write_and_send_entries(&broadcast, &blob_recycler, &writer);
|
||||
if exit.load(Ordering::Relaxed) {
|
||||
info!("broadcat_service exiting");
|
||||
|
@ -55,7 +55,7 @@ impl Tpu {
|
|||
|
||||
pub fn drain_service(obj: SharedTpu, exit: Arc<AtomicBool>) -> JoinHandle<()> {
|
||||
spawn(move || {
|
||||
let entry_writer = EntryWriter::new(&obj.accounting_stage, &obj.thin_client_service);
|
||||
let entry_writer = EntryWriter::new(&obj.accounting_stage, &obj.request_processor);
|
||||
loop {
|
||||
let _ = entry_writer.drain_entries();
|
||||
if exit.load(Ordering::Relaxed) {
|
||||
|
@ -75,7 +75,7 @@ impl Tpu {
|
|||
blob_recycler: packet::BlobRecycler,
|
||||
) -> JoinHandle<()> {
|
||||
spawn(move || loop {
|
||||
let e = obj.thin_client_service.process_request_packets(
|
||||
let e = obj.request_processor.process_request_packets(
|
||||
&obj.accounting_stage,
|
||||
&verified_receiver,
|
||||
&responder_sender,
|
||||
|
|
Loading…
Reference in New Issue