Skip to content

Commit

Permalink
Set correct flags when encoding cassandra frame (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Oct 19, 2022
1 parent 6b613d3 commit 0e83fec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shotover-proxy/src/codec/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ mod cassandra_protocol_tests {
fn test_codec_result() {
let mut codec = CassandraCodec::new();
let bytes = hex!(
"040000020800000099000000020000000100000009000673797374656
"840000020800000099000000020000000100000009000673797374656
d000570656572730004706565720010000b646174615f63656e746572000d0007686f73745f6964000c000c70726566
65727265645f6970001000047261636b000d000f72656c656173655f76657273696f6e000d000b7270635f616464726
573730010000e736368656d615f76657273696f6e000c0006746f6b656e730022000d00000000"
Expand Down
8 changes: 6 additions & 2 deletions shotover-proxy/src/frame/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,14 @@ impl CassandraFrame {
}

pub fn encode(self) -> RawCassandraFrame {
let mut flags = Flags::empty();
flags.set(Flags::WARNING, !self.warnings.is_empty());
flags.set(Flags::TRACING, self.tracing_id.is_some());

RawCassandraFrame {
direction: self.operation.to_direction(),
version: self.version,
flags: Flags::default(),
flags,
opcode: self.operation.to_opcode(),
stream_id: self.stream_id,
body: self.operation.into_body(self.version),
Expand Down Expand Up @@ -387,7 +391,7 @@ impl CassandraOperation {
fn to_direction(&self) -> Direction {
match self {
CassandraOperation::Query { .. } => Direction::Request,
CassandraOperation::Result { .. } => Direction::Request,
CassandraOperation::Result { .. } => Direction::Response,
CassandraOperation::Error(_) => Direction::Response,
CassandraOperation::Startup(_) => Direction::Request,
CassandraOperation::Ready(_) => Direction::Response,
Expand Down

0 comments on commit 0e83fec

Please sign in to comment.