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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ env-file
parseable
parseable_*
parseable-env-secret
cache
cache*

11 changes: 10 additions & 1 deletion server/src/handlers/http/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ pub async fn put_enable_cache(
let stream_name: String = req.match_info().get("logstream").unwrap().parse().unwrap();
let storage = CONFIG.storage().get_object_store();

if CONFIG.parseable.local_cache_path.is_none() {
return Err(StreamError::CacheNotEnabled(stream_name));
}

let mut stream_metadata = storage.get_stream_metadata(&stream_name).await?;
stream_metadata.cache_enabled = enable_cache;
storage
Expand All @@ -249,7 +253,7 @@ pub async fn put_enable_cache(

STREAM_INFO.set_stream_cache(&stream_name, enable_cache)?;
Ok((
format!("Cache setting updated for log stream {stream_name}"),
format!("Cache set to {enable_cache} for log stream {stream_name}"),
StatusCode::OK,
))
}
Expand Down Expand Up @@ -336,6 +340,10 @@ pub mod error {
CreateStream(#[from] CreateStreamError),
#[error("Log stream {0} does not exist")]
StreamNotFound(String),
#[error(
"Caching not enabled at Parseable server config. Can't enable cache for stream {0}"
)]
CacheNotEnabled(String),
#[error("Log stream is not initialized, send an event to this logstream and try again")]
UninitializedLogstream,
#[error("Storage Error {0}")]
Expand Down Expand Up @@ -370,6 +378,7 @@ pub mod error {
StreamError::CreateStream(CreateStreamError::Storage { .. }) => {
StatusCode::INTERNAL_SERVER_ERROR
}
StreamError::CacheNotEnabled(_) => StatusCode::BAD_REQUEST,
StreamError::StreamNotFound(_) => StatusCode::NOT_FOUND,
StreamError::Custom { status, .. } => *status,
StreamError::UninitializedLogstream => StatusCode::METHOD_NOT_ALLOWED,
Expand Down
2 changes: 1 addition & 1 deletion server/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub mod error {

#[derive(Debug, thiserror::Error)]
pub enum MetadataError {
#[error("Metadata for stream {0} not found. Maybe the stream does not exist")]
#[error("Metadata for stream {0} not found. Please create the stream and try again")]
StreamMetaNotFound(String),
}

Expand Down