Skip to content

Commit 5cba3a8

Browse files
committed
chore: purge scripting
1 parent 8ee5a69 commit 5cba3a8

File tree

6 files changed

+13
-50
lines changed

6 files changed

+13
-50
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub mod hyperloglog;
2020
pub mod keys;
2121
pub mod lists;
2222
pub mod misc;
23-
pub mod scripting;
2423
pub mod server;
2524
pub mod sets;
2625
pub mod sorted_sets;

src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use lazy_static::lazy_static;
66
use slog::Logger;
77
use sloggers::terminal::{Destination, TerminalLoggerBuilder};
8-
use sloggers::types::{Severity, SourceLocation};
8+
use sloggers::types::{Severity};
99
use sloggers::Build;
1010

1111
#[cfg(debug_assertions)]

src/main.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use redis_proto::database::{get_dump_file, load_state, save_state_interval};
22
use redis_proto::logger::LOGGER;
3-
use redis_proto::scripting::{handle_redis_cmd, ScriptingBridge, ScriptingEngine};
43
use redis_proto::server::socket_listener;
54
use redis_proto::startup::{startup_message, Config};
6-
use tokio::sync::mpsc::channel;
5+
76

87
use slog::{info, warn};
98
use structopt::StructOpt;
@@ -31,26 +30,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3130
"Database is in memory-only mode. STATE WILL NOT BE SAVED!"
3231
);
3332
}
34-
// Create the channels for scripting
35-
let (prog_string_sx, prog_string_rx) = channel(12);
36-
let (cmd_result_sx, cmd_result_rx) = channel(12);
37-
38-
let scripting_engine =
39-
ScriptingEngine::new(prog_string_rx, cmd_result_sx, state.clone(), &opt)?;
40-
41-
info!(LOGGER, "ScriptingEngine main loop started");
42-
std::thread::spawn(|| scripting_engine.main_loop());
43-
44-
let scripting_bridge = ScriptingBridge::new(prog_string_sx);
45-
46-
tokio::spawn(handle_redis_cmd(
47-
cmd_result_rx,
48-
state.clone(),
49-
dump_file.clone(),
50-
scripting_bridge.clone(),
51-
));
5233

5334
// Start the server! It will start listening for connections.
54-
socket_listener(state.clone(), dump_file.clone(), opt, scripting_bridge).await;
35+
socket_listener(state.clone(), dump_file.clone(), opt).await;
5536
Ok(())
5637
}

src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::Arc;
1+
22

33
/// use crate::scripting::{Program, ScriptingBridge};
44
use crate::types::{Count, Index, Key, RedisValueRef, ReturnValue, StateRef, StateStoreRef, Value};

src/scripting.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/server.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
/// Server launch file. Starts the services to make redis-proto work.
2+
use crate::asyncresp::RespParser;
13
use crate::database::save_state;
24
use crate::misc::misc_interact;
35
use crate::ops::{op_interact, Ops};
4-
/// Server launch file. Starts the services to make redis-proto work.
5-
use crate::asyncresp::RespParser;
66
use crate::{logger::LOGGER, types::StateRef};
77
use crate::{
88
ops::translate,
@@ -13,7 +13,7 @@ use futures::StreamExt;
1313
use futures_util::sink::SinkExt;
1414
use slog::{debug, error, info};
1515
use std::sync::atomic::Ordering;
16-
use std::{net::SocketAddr, sync::Arc};
16+
use std::net::SocketAddr;
1717
use tokio::net::{TcpListener, TcpStream};
1818
use tokio_util::codec::Decoder;
1919

@@ -45,9 +45,7 @@ pub async fn process_command(
4545
debug!(LOGGER, "running op {:?}", op.clone());
4646
// Step 1: Execute the operation the operation (from translate above)
4747
let res: ReturnValue = match op {
48-
Ops::Misc(op) => {
49-
misc_interact(op, state, state_store.clone()),
50-
}
48+
Ops::Misc(op) => misc_interact(op, state, state_store.clone()).await,
5149
_ => op_interact(op, state.clone()).await,
5250
};
5351
// Step 2: Update commands_ran_since_save counter, and save if necessary
@@ -66,11 +64,7 @@ pub async fn process_command(
6664
/// This will synchronously process requests / responses for this
6765
/// connection only. Other connections will be spread across the
6866
/// thread pool.
69-
async fn process(
70-
socket: TcpStream,
71-
state_store: StateStoreRef,
72-
dump_file: Dumpfile,
73-
) {
67+
async fn process(socket: TcpStream, state_store: StateStoreRef, dump_file: Dumpfile) {
7468
tokio::spawn(async move {
7569
let mut state = state_store.get_default();
7670
let mut transport = RespParser.framed(socket);
@@ -83,7 +77,7 @@ async fn process(
8377
&mut state,
8478
state_store.clone(),
8579
dump_file.clone(),
86-
redis_value.unwrap(),
80+
redis_value.unwrap(),
8781
)
8882
.await;
8983
// let res = match translate(redis_value.unwrap()) {
@@ -96,7 +90,7 @@ async fn process(
9690
// op,
9791
// &mut state,
9892
// state_store.clone(),
99-
//
93+
//
10094
// )
10195
// .await
10296
// }
@@ -119,11 +113,7 @@ async fn process(
119113
}
120114

121115
/// The listener for redis-proto. Accepts connections and spawns handlers.
122-
pub async fn socket_listener(
123-
state_store: StateStoreRef,
124-
dump_file: Dumpfile,
125-
config: Config,
126-
) {
116+
pub async fn socket_listener(state_store: StateStoreRef, dump_file: Dumpfile, config: Config) {
127117
// First, get the address determined and parsed.
128118
let addr_str = format!("{}:{}", "127.0.0.1", config.port);
129119
let addr = match addr_str.parse::<SocketAddr>() {
@@ -159,13 +149,7 @@ pub async fn socket_listener(
159149
match listener.accept().await {
160150
Ok((socket, _)) => {
161151
debug!(LOGGER, "Accepted connection!");
162-
process(
163-
socket,
164-
state_store.clone(),
165-
dump_file.clone(),
166-
167-
)
168-
.await;
152+
process(socket, state_store.clone(), dump_file.clone()).await;
169153
}
170154
Err(e) => error!(LOGGER, "Failed to establish connectin: {:?}", e),
171155
};

0 commit comments

Comments
 (0)