Skip to content

Commit

Permalink
Merge pull request #26 from superfly/cleanup
Browse files Browse the repository at this point in the history
Cleanup some dead code
  • Loading branch information
jeromegn authored Aug 18, 2023
2 parents 111aa57 + e1c0207 commit 357623e
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 90 deletions.
12 changes: 0 additions & 12 deletions NOTES.md

This file was deleted.

5 changes: 0 additions & 5 deletions crates/corro-agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2053,11 +2053,6 @@ pub mod tests {
assert_eq!(svc.id, 1);
assert_eq!(svc.text, "hello world 1");

// assert_eq!(
// bod["outcomes"],
// serde_json::json!([{"result": "applied", "version": 1}])
// );

let req_body: Vec<Statement> = serde_json::from_value(json!([[
"INSERT INTO tests (id,text) VALUES (?,?)",
[2, "hello world 2"]
Expand Down
10 changes: 0 additions & 10 deletions crates/corro-agent/src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ use crate::agent::process_subs;

pub const MAX_CHANGES_PER_MESSAGE: usize = 50;

// TODO: accept a few options
// #[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
// #[serde(rename_all = "snake_case")]
// pub struct RqliteRequestOptions {
// pretty: Option<bool>,
// timings: Option<bool>,
// transaction: Option<bool>,
// q: Option<String>,
// }

pub struct ChunkedChanges<I> {
iter: I,
changes: Vec<Change>,
Expand Down
3 changes: 0 additions & 3 deletions crates/corro-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ impl CorrosionApiClient {
match tokio::fs::read_to_string(entry.path()).await {
Ok(s) => {
statements.push(Statement::Simple(s));
// pushed.push(
// entry.path().to_string_lossy().to_string().into(),
// );
}
Err(e) => {
warn!(
Expand Down
26 changes: 0 additions & 26 deletions crates/corro-tpl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,20 +676,6 @@ mod tests {
let tmpdir = tempfile::tempdir().unwrap();
let filepath = tmpdir.path().join("output");

// enum Command {
// Render,
// }

// enum Reply {
// Rendered,
// }

// let (cmd_tx, mut cmd_rx) = mpsc::channel(10);
// let (reply_tx, mut reply_rx) = mpsc::channel(10);

// tokio::spawn({
// let filepath = filepath.clone();
// async move {
let f = std::fs::OpenOptions::new()
.create(true)
.write(true)
Expand All @@ -700,10 +686,6 @@ mod tests {

let engine = Engine::new::<std::fs::File>(client.clone());

// loop {
// let cmd = cmd_rx.recv().await.unwrap();
// assert!(matches!(cmd, Command::Render));

{
let cancel = CancellationToken::new();
block_in_place(|| {
Expand All @@ -720,14 +702,6 @@ mod tests {
)
.unwrap();
});
// reply_tx.send(Reply::Rendered).await.unwrap();
// }
// }
// });

// cmd_tx.send(Command::Render).await.unwrap();
// let replied = reply_rx.recv().await.unwrap();
// assert!(matches!(replied, Reply::Rendered));

let output = std::fs::read_to_string(&filepath).unwrap();

Expand Down
36 changes: 2 additions & 34 deletions crates/corro-types/src/sync.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{collections::HashMap, io, ops::RangeInclusive};

use bytes::{BufMut, BytesMut};
use bytes::BytesMut;
use serde::{Deserialize, Serialize};
use speedy::{Readable, Writable};
use tokio_util::codec::{Decoder, Encoder, LengthDelimitedCodec};
use tokio_util::codec::{Decoder, LengthDelimitedCodec};

use crate::{
actor::ActorId,
Expand Down Expand Up @@ -142,39 +142,7 @@ impl SyncMessage {
Self::read_from_buffer(slice.as_ref())
}

pub fn encode_w_codec(
&self,
codec: &mut LengthDelimitedCodec,
buf: &mut BytesMut,
) -> Result<(), SyncMessageEncodeError> {
self.write_to_stream(buf.writer())?;
// let mut bytes = buf.split();
// let hash = crc32fast::hash(&bytes);
// bytes.put_u32(hash);

codec.encode(buf.split().freeze(), buf)?;

Ok(())
}

// pub fn encode(&self, buf: &mut BytesMut) -> Result<(), SyncMessageEncodeError> {
// let mut codec = LengthDelimitedCodec::builder()
// .length_field_type::<u32>()
// .new_codec();
// self.encode_w_codec(&mut codec, buf)?;

// Ok(())
// }

pub fn from_buf(buf: &mut BytesMut) -> Result<Self, SyncMessageDecodeError> {
// let mut crc_bytes = buf.split_off(len - 4);

// let crc = crc_bytes.get_u32();
// let new_crc = crc32fast::hash(&buf);
// if crc != new_crc {
// return Err(SyncMessageDecodeError::Corrupted(crc, new_crc));
// }

Ok(Self::from_slice(&buf)?)
}

Expand Down

0 comments on commit 357623e

Please sign in to comment.