Skip to content

Commit

Permalink
cleanup code layout
Browse files Browse the repository at this point in the history
Re-organize the various client types to provide more coherent structure.
  • Loading branch information
brayniac committed Sep 24, 2024
1 parent 2145075 commit bf50135
Show file tree
Hide file tree
Showing 75 changed files with 106 additions and 644 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::clients::ResponseError;
use super::*;
use crate::net::Connector;
use protocol_memcache::{Compose, Parse, Request, Response, Ttl};
Expand Down
52 changes: 52 additions & 0 deletions src/clients/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use crate::workload::ClientRequest;
use crate::*;

use async_channel::Receiver;
use tokio::io::*;
use tokio::runtime::Runtime;
use tokio::time::{timeout, Duration};
use workload::ClientWorkItemKind;

use std::io::{Error, ErrorKind, Result};
use std::time::Instant;

mod memcache;
mod momento;
mod redis;

pub fn launch(
config: &Config,
work_receiver: Receiver<ClientWorkItemKind<ClientRequest>>,
) -> Option<Runtime> {
debug!("Launching clients...");

config.client()?;

// spawn the request drivers on their own runtime
let mut client_rt = Builder::new_multi_thread()
.enable_all()
.worker_threads(config.client().unwrap().threads())
.build()
.expect("failed to initialize tokio runtime");

match config.general().protocol() {
Protocol::Memcache => {
memcache::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Momento => {
momento::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Ping => {
crate::clients::ping::ascii::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
Protocol::Resp => {
redis::launch_tasks(&mut client_rt, config.clone(), work_receiver)
}
protocol => {
error!("keyspace is not supported for the {:?} protocol", protocol);
std::process::exit(1);
}
}

Some(client_rt)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use crate::clients::*;

use ::momento::cache::configurations::LowLatency;
use ::momento::*;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/clients/redis/mod.rs → src/clients/cache/redis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use crate::clients::cache::*;
use crate::clients::*;
use crate::net::Connector;
use ::redis::aio::Connection;
use ::redis::{AsyncCommands, RedisConnectionInfo};
Expand Down
237 changes: 0 additions & 237 deletions src/clients/http1.rs

This file was deleted.

Loading

0 comments on commit bf50135

Please sign in to comment.