Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Error handling #210

Merged
merged 20 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 14 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
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion meilisearch-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ main_error = "0.1.0"
meilisearch-error = { path = "../meilisearch-error" }
meilisearch-tokenizer = { git = "https://github.com/meilisearch/Tokenizer.git", tag = "v0.2.2" }
memmap = "0.7.0"
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.4.0" }
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.4.1" }
mime = "0.3.16"
once_cell = "1.5.2"
oxidized-json-checker = "0.3.2"
Expand Down
18 changes: 9 additions & 9 deletions meilisearch-http/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use sha2::Digest;

use crate::index::{Checked, Settings};
use crate::index_controller::{
DumpInfo, IndexController, IndexMetadata, IndexSettings, IndexStats, Stats,
error::Result, DumpInfo, IndexController, IndexMetadata, IndexSettings, IndexStats, Stats,
};
use crate::option::Opt;

Expand Down Expand Up @@ -79,23 +79,23 @@ impl Data {
Ok(Data { inner })
}

pub async fn settings(&self, uid: String) -> anyhow::Result<Settings<Checked>> {
pub async fn settings(&self, uid: String) -> Result<Settings<Checked>> {
self.index_controller.settings(uid).await
}

pub async fn list_indexes(&self) -> anyhow::Result<Vec<IndexMetadata>> {
pub async fn list_indexes(&self) -> Result<Vec<IndexMetadata>> {
self.index_controller.list_indexes().await
}

pub async fn index(&self, uid: String) -> anyhow::Result<IndexMetadata> {
pub async fn index(&self, uid: String) -> Result<IndexMetadata> {
self.index_controller.get_index(uid).await
}

pub async fn create_index(
&self,
uid: String,
primary_key: Option<String>,
) -> anyhow::Result<IndexMetadata> {
) -> Result<IndexMetadata> {
let settings = IndexSettings {
uid: Some(uid),
primary_key,
Expand All @@ -105,19 +105,19 @@ impl Data {
Ok(meta)
}

pub async fn get_index_stats(&self, uid: String) -> anyhow::Result<IndexStats> {
pub async fn get_index_stats(&self, uid: String) -> Result<IndexStats> {
Ok(self.index_controller.get_index_stats(uid).await?)
}

pub async fn get_all_stats(&self) -> anyhow::Result<Stats> {
pub async fn get_all_stats(&self) -> Result<Stats> {
Ok(self.index_controller.get_all_stats().await?)
}

pub async fn create_dump(&self) -> anyhow::Result<DumpInfo> {
pub async fn create_dump(&self) -> Result<DumpInfo> {
Ok(self.index_controller.create_dump().await?)
}

pub async fn dump_status(&self, uid: String) -> anyhow::Result<DumpInfo> {
pub async fn dump_status(&self, uid: String) -> Result<DumpInfo> {
Ok(self.index_controller.dump_info(uid).await?)
}

Expand Down
11 changes: 4 additions & 7 deletions meilisearch-http/src/data/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use serde_json::{Map, Value};

use super::Data;
use crate::index::{SearchQuery, SearchResult};
use crate::index_controller::error::Result;

impl Data {
pub async fn search(
&self,
index: String,
search_query: SearchQuery,
) -> anyhow::Result<SearchResult> {
pub async fn search(&self, index: String, search_query: SearchQuery) -> Result<SearchResult> {
self.index_controller.search(index, search_query).await
}

Expand All @@ -18,7 +15,7 @@ impl Data {
offset: usize,
limit: usize,
attributes_to_retrieve: Option<Vec<String>>,
) -> anyhow::Result<Vec<Map<String, Value>>> {
) -> Result<Vec<Map<String, Value>>> {
self.index_controller
.documents(index, offset, limit, attributes_to_retrieve)
.await
Expand All @@ -29,7 +26,7 @@ impl Data {
index: String,
document_id: String,
attributes_to_retrieve: Option<Vec<String>>,
) -> anyhow::Result<Map<String, Value>> {
) -> Result<Map<String, Value>> {
self.index_controller
.document(index, document_id, attributes_to_retrieve)
.await
Expand Down
18 changes: 9 additions & 9 deletions meilisearch-http/src/data/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use milli::update::{IndexDocumentsMethod, UpdateFormat};

use super::Data;
use crate::index::{Checked, Settings};
use crate::index_controller::{IndexMetadata, IndexSettings, UpdateStatus};
use crate::index_controller::{error::Result, IndexMetadata, IndexSettings, UpdateStatus};

impl Data {
pub async fn add_documents(
Expand All @@ -13,7 +13,7 @@ impl Data {
format: UpdateFormat,
stream: Payload,
primary_key: Option<String>,
) -> anyhow::Result<UpdateStatus> {
) -> Result<UpdateStatus> {
let update_status = self
.index_controller
.add_documents(index, method, format, stream, primary_key)
Expand All @@ -26,15 +26,15 @@ impl Data {
index: String,
settings: Settings<Checked>,
create: bool,
) -> anyhow::Result<UpdateStatus> {
) -> Result<UpdateStatus> {
let update = self
.index_controller
.update_settings(index, settings, create)
.await?;
Ok(update)
}

pub async fn clear_documents(&self, index: String) -> anyhow::Result<UpdateStatus> {
pub async fn clear_documents(&self, index: String) -> Result<UpdateStatus> {
let update = self.index_controller.clear_documents(index).await?;
Ok(update)
}
Expand All @@ -43,24 +43,24 @@ impl Data {
&self,
index: String,
document_ids: Vec<String>,
) -> anyhow::Result<UpdateStatus> {
) -> Result<UpdateStatus> {
let update = self
.index_controller
.delete_documents(index, document_ids)
.await?;
Ok(update)
}

pub async fn delete_index(&self, index: String) -> anyhow::Result<()> {
pub async fn delete_index(&self, index: String) -> Result<()> {
self.index_controller.delete_index(index).await?;
Ok(())
}

pub async fn get_update_status(&self, index: String, uid: u64) -> anyhow::Result<UpdateStatus> {
pub async fn get_update_status(&self, index: String, uid: u64) -> Result<UpdateStatus> {
self.index_controller.update_status(index, uid).await
}

pub async fn get_updates_status(&self, index: String) -> anyhow::Result<Vec<UpdateStatus>> {
pub async fn get_updates_status(&self, index: String) -> Result<Vec<UpdateStatus>> {
self.index_controller.all_update_status(index).await
}

Expand All @@ -69,7 +69,7 @@ impl Data {
uid: String,
primary_key: Option<String>,
new_uid: Option<String>,
) -> anyhow::Result<IndexMetadata> {
) -> Result<IndexMetadata> {
let settings = IndexSettings {
uid: new_uid,
primary_key,
Expand Down
Loading