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
7 changes: 5 additions & 2 deletions server/src/storage/localfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ use relative_path::{RelativePath, RelativePathBuf};
use tokio::fs::{self, DirEntry};
use tokio_stream::wrappers::ReadDirStream;

use crate::metrics::storage::{localfs::REQUEST_RESPONSE_TIME, StorageMetrics};
use crate::option::validation;
use crate::{
handlers::http::users::USERS_ROOT_DIR,
metrics::storage::{localfs::REQUEST_RESPONSE_TIME, StorageMetrics},
};

use super::{
LogStream, ObjectStorage, ObjectStorageError, ObjectStorageProvider, PARSEABLE_ROOT_DIRECTORY,
Expand Down Expand Up @@ -291,7 +294,7 @@ impl ObjectStorage for LocalFS {
}

async fn list_streams(&self) -> Result<Vec<LogStream>, ObjectStorageError> {
let ignore_dir = &["lost+found", PARSEABLE_ROOT_DIRECTORY];
let ignore_dir = &["lost+found", PARSEABLE_ROOT_DIRECTORY, USERS_ROOT_DIR];
let directories = ReadDirStream::new(fs::read_dir(&self.root).await?);
let entries: Vec<DirEntry> = directories.try_collect().await?;
let entries = entries
Expand Down
35 changes: 32 additions & 3 deletions server/src/users/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,45 @@ use crate::{handlers::http::users::USERS_ROOT_DIR, metadata::LOCK_EXPECT, option

pub static FILTERS: Lazy<Filters> = Lazy::new(Filters::default);

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Filter {
version: String,
stream_name: String,
filter_name: String,
filter_id: String,
query: String,
query: FilterQuery,
time_filter: Option<TimeFilter>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct FilterQuery {
filter_type: String,
filter_query: Option<String>,
filter_builder: Option<FilterBuilder>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct FilterBuilder {
id: String,
combinator: String,
rules: Vec<FilterRules>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct FilterRules {
id: String,
combinator: String,
rules: Vec<Rules>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Rules {
id: String,
field: String,
value: String,
operator: String,
}

impl Filter {
pub fn filter_id(&self) -> &str {
&self.filter_id
Expand Down Expand Up @@ -70,7 +99,7 @@ impl Filters {

pub fn update(&self, filter: Filter) {
let mut s = self.0.write().expect(LOCK_EXPECT);

s.retain(|f| f.filter_id() != filter.filter_id());
s.push(filter);
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/users/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod filters;

use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Default, Clone)]
#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq)]
pub struct TimeFilter {
to: String,
from: String,
Expand Down