Skip to content

Commit

Permalink
chore: Remove scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
obaraelijah committed Jul 28, 2024
1 parent 496cbef commit 8ee5a69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
19 changes: 2 additions & 17 deletions src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pub async fn misc_interact(
misc_op: MiscOps,
state: &mut StateRef,
state_store: StateStoreRef,
scripting_bridge: Arc<ScriptingBridge>,
) -> ReturnValue {
match misc_op {
MiscOps::Pong() => ReturnValue::StringRes(Value::from_static(b"PONG")),
Expand Down Expand Up @@ -123,21 +122,7 @@ pub async fn misc_interact(
.join("\r\n");
ReturnValue::StringRes(info.into())
}
MiscOps::Script(program) => {
let prog_str = String::from_utf8_lossy(&program).to_string();
let res = scripting_bridge
.handle_script_cmd(Program::String(prog_str))
.await;
ReturnValue::Ident(res)
}
MiscOps::EmbeddedScript(fn_name, fn_args) => {
// We need to send the program over the scripting bridge
// and wait for the result
let fn_name = String::from_utf8_lossy(&fn_name).to_string();
let res = scripting_bridge
.handle_script_cmd(Program::Function(fn_name, fn_args))
.await;
ReturnValue::Ident(res)
}
MiscOps::Script(_) => todo!(),
MiscOps::EmbeddedScript(_, _) => todo!(),
}
}
14 changes: 5 additions & 9 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::database::save_state;
use crate::misc::misc_interact;

Check warning on line 2 in src/server.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `crate::misc::misc_interact`

Check warning on line 2 in src/server.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `crate::misc::misc_interact`
use crate::ops::{op_interact, Ops};
/// Server launch file. Starts the services to make redis-proto work.
use crate::{asyncresp::RespParser, scripting::ScriptingBridge};
use crate::asyncresp::RespParser;
use crate::{logger::LOGGER, types::StateRef};
use crate::{
ops::translate,
Expand Down Expand Up @@ -38,7 +38,6 @@ pub async fn process_command(
state: &mut StateRef,
state_store: StateStoreRef,
dump_file: Dumpfile,
scripting_bridge: Arc<ScriptingBridge>,
redis_value: RedisValueRef,
) -> RedisValueRef {
match translate(redis_value, state_store.clone()) {
Expand All @@ -47,7 +46,7 @@ pub async fn process_command(
// Step 1: Execute the operation the operation (from translate above)
let res: ReturnValue = match op {
Ops::Misc(op) => {
misc_interact(op, state, state_store.clone(), scripting_bridge.clone()).await
misc_interact(op, state, state_store.clone()),

Check failure on line 49 in src/server.rs

View workflow job for this annotation

GitHub Actions / Check

expected one of `.`, `;`, `?`, `}`, or an operator, found `,`

Check failure on line 49 in src/server.rs

View workflow job for this annotation

GitHub Actions / Test Suite

expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
}
_ => op_interact(op, state.clone()).await,
};
Expand All @@ -71,7 +70,6 @@ async fn process(
socket: TcpStream,
state_store: StateStoreRef,
dump_file: Dumpfile,
scripting_bridge: Arc<ScriptingBridge>,
) {
tokio::spawn(async move {
let mut state = state_store.get_default();
Expand All @@ -85,8 +83,7 @@ async fn process(
&mut state,
state_store.clone(),
dump_file.clone(),
scripting_bridge.clone(),
redis_value.unwrap(),
redis_value.unwrap(),
)
.await;
// let res = match translate(redis_value.unwrap()) {
Expand All @@ -99,7 +96,7 @@ async fn process(
// op,
// &mut state,
// state_store.clone(),
// scripting_bridge.clone(),
//
// )
// .await
// }
Expand All @@ -126,7 +123,6 @@ pub async fn socket_listener(
state_store: StateStoreRef,
dump_file: Dumpfile,
config: Config,
scripting_bridge: Arc<ScriptingBridge>,
) {
// First, get the address determined and parsed.
let addr_str = format!("{}:{}", "127.0.0.1", config.port);
Expand Down Expand Up @@ -167,7 +163,7 @@ pub async fn socket_listener(
socket,
state_store.clone(),
dump_file.clone(),
scripting_bridge.clone(),

)
.await;
}
Expand Down

0 comments on commit 8ee5a69

Please sign in to comment.