Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce pelikan_bloomcache #468

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Add entrystore entry for bloom server using http
swlynch99 committed Oct 6, 2022

Verified

This commit was signed with the committer’s verified signature.
commit 305e36695f413c5b8a0d9e2b972ce5b7011bec8c
4 changes: 3 additions & 1 deletion src/entrystore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -18,4 +18,6 @@ config = { path = "../config" }
protocol-common = { path = "../protocol/common" }
protocol-memcache = { path = "../protocol/memcache" }
protocol-ping = { path = "../protocol/ping" }
seg = { path = "../storage/seg" }
protocol-http = { path = "../protocol/http" }
seg = { path = "../storage/seg" }
bloom = { path = "../storage/bloom" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer alphabetical ordering

26 changes: 15 additions & 11 deletions src/entrystore/src/bloom/http.rs
Original file line number Diff line number Diff line change
@@ -2,19 +2,17 @@
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

use std::borrow::Cow;

use protocol_common::Execute;
use protocol_http::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not use this style here and would prefer two use statements.

request::{Request, RequestData},
Headers, ParseResult, Response, Storage,
request::{ParseData, Request, RequestData},
Headers, Response, Storage,
};

use crate::Bloom;

impl Execute<ParseResult, Response> for Bloom {
fn execute(&mut self, result: &ParseResult) -> Response {
let request = match result {
impl Execute<ParseData, Response> for Bloom {
fn execute(&mut self, data: &ParseData) -> Response {
let request = match &data.0 {
Ok(request) => request,
Err(e) => return e.to_response(),
};
@@ -31,20 +29,26 @@ impl Execute<ParseResult, Response> for Bloom {
impl Storage for Bloom {
fn get(&mut self, key: &[u8], _headers: &Headers) -> Response {
if self.data.contains(key) {
Response::builder(204).empty()
Response::builder(200).body(b"")
} else {
Response::builder(404).empty()
Response::builder(404).body(b"")
}
}

fn put(&mut self, key: &[u8], _value: &[u8], _headers: &Headers) -> Response {
let exists = self.data.contains(key);
self.data.insert(key);
Response::builder(204).empty()

if exists {
Response::builder(200).body(b"")
} else {
Response::builder(201).body(b"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we us named status codes? Had to look this one up.

}
}

fn delete(&mut self, _key: &[u8], _headers: &Headers) -> Response {
let mut builder = Response::builder(405);
builder.header("Content-Type", b"text/plain");
builder.body(Cow::Borrowed(b"DELETE method not supported"))
builder.body(b"DELETE method not supported")
}
}
2 changes: 2 additions & 0 deletions src/entrystore/src/lib.rs
Original file line number Diff line number Diff line change
@@ -7,9 +7,11 @@
//! addition to the base `EntryStore` trait. For example [`Seg`] implements both
//! [`EntryStore`] and [`protocol::memcache::MemcacheStorage`].

mod bloom;
mod noop;
mod seg;

pub use self::bloom::Bloom;
pub use self::noop::*;
pub use self::seg::*;