Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
target
data
staging
limitcache
examples
cert.pem
key.pem
Expand Down
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ xxhash-rust = { version = "0.8", features = ["xxh3"] }
xz2 = { version = "*", features = ["static"] }
nom = "7.1.3"
humantime = "2.1.0"
human-size = "0.4"
openid = { version = "0.12.0", default-features = false, features = ["rustls"] }
url = "2.4.0"
http-auth-basic = "0.3.3"
serde_repr = "0.1.17"
hashlru = { version = "0.11.0", features = ["serde"] }

[build-dependencies]
cargo_toml = "0.15"
Expand Down
19 changes: 18 additions & 1 deletion server/src/banner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

use crossterm::style::Stylize;
use human_size::SpecificSize;

use crate::about;
use crate::utils::uid::Uid;
Expand Down Expand Up @@ -100,5 +101,21 @@ async fn storage_info(config: &Config) {
config.staging_dir().to_string_lossy(),
storage.get_endpoint(),
latency
)
);

if let Some(path) = &config.parseable.local_cache_path {
let size: SpecificSize<human_size::Gigabyte> =
SpecificSize::new(config.parseable.local_cache_size as f64, human_size::Byte)
.unwrap()
.into();

eprintln!(
"\
{:8}Cache: \"{}\"
Cache Size: \"{}\"",
"",
path.display(),
size
);
}
}
15 changes: 15 additions & 0 deletions server/src/handlers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ pub fn configure_routes(
.to(logstream::get_retention)
.authorize_for_stream(Action::GetRetention),
),
)
.service(
web::resource("/cache")
// PUT "/logstream/{logstream}/cache" ==> Set retention for given logstream
.route(
web::put()
.to(logstream::put_enable_cache)
.authorize_for_stream(Action::PutCacheEnabled),
)
// GET "/logstream/{logstream}/cache" ==> Get retention for given logstream
.route(
web::get()
.to(logstream::get_cache_enabled)
.authorize_for_stream(Action::GetCacheEnabled),
),
);

// User API
Expand Down
27 changes: 27 additions & 0 deletions server/src/handlers/http/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,33 @@ pub async fn put_retention(
))
}

pub async fn get_cache_enabled(req: HttpRequest) -> Result<impl Responder, StreamError> {
let stream_name: String = req.match_info().get("logstream").unwrap().parse().unwrap();
let cache_enabled = STREAM_INFO.cache_enabled(&stream_name)?;
Ok((web::Json(cache_enabled), StatusCode::OK))
}

pub async fn put_enable_cache(
req: HttpRequest,
body: web::Json<bool>,
) -> Result<impl Responder, StreamError> {
let enable_cache = body.into_inner();
let stream_name: String = req.match_info().get("logstream").unwrap().parse().unwrap();
let storage = CONFIG.storage().get_object_store();

let mut stream_metadata = storage.get_stream_metadata(&stream_name).await?;
stream_metadata.cache_enabled = enable_cache;
storage
.put_stream_manifest(&stream_name, &stream_metadata)
.await?;

STREAM_INFO.set_stream_cache(&stream_name, enable_cache)?;
Ok((
format!("Cache setting updated for log stream {stream_name}"),
StatusCode::OK,
))
}

pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError> {
let stream_name: String = req.match_info().get("logstream").unwrap().parse().unwrap();

Expand Down
Loading