Skip to content

Commit 3aa6bef

Browse files
bors[bot]curquiza
andauthored
Merge #58
58: Changes about the MeiliSearch's next release (v0.16.0) r=curquiza a=curquiza Related to this issue: meilisearch/integration-guides#52 - [x] Update README - [x] Remove `set_health` method and rename method `get_health` into `health` #59 This PR: - gathers the changes related to the next release of MeiliSearch (v0.16.0) so that this package is ready when the official release is out. - should pass the tests against the [latest prerelease of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases). This should be tested locally. - might eventually fail until the MeiliSearch v0.16.0 is out. ⚠️ This PR should NOT be merged until the MeiliSearch's next release (v0.16.0) is out. Co-authored-by: Clementine Urquizar <[email protected]> Co-authored-by: Clémentine Urquizar <[email protected]>
2 parents 8e87d8c + 606c4d3 commit 3aa6bef

File tree

5 files changed

+9
-48
lines changed

5 files changed

+9
-48
lines changed

.code-samples.meilisearch.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,8 @@ get_index_stats_1: |-
193193
get_indexes_stats_1: |-
194194
let stats: ClientStats = client.get_stats().await.unwrap();
195195
get_health_1: |-
196-
// get_health() return an Err() if the server is not healthy, so this example would panic due to the unwrap
197-
client.get_health().await.unwrap();
198-
update_health_1: |-
199-
client.set_health(false).await.unwrap();
196+
// health() return an Err() if the server is not healthy, so this example would panic due to the unwrap
197+
client.health().await.unwrap();
200198
get_version_1: |-
201199
let version: Version = client.get_version().await.unwrap();
202200
distinct_attribute_guide_1: |-

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi
139139

140140
## 🤖 Compatibility with MeiliSearch
141141

142-
This package only guarantees the compatibility with the [version v0.15.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.15.0).
142+
This package only guarantees the compatibility with the [version v0.16.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.16.0).
143143

144144
## ⚙️ Development Workflow and Contributing
145145

README.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ See our [Documentation](https://docs.meilisearch.com/guides/introduction/quick_s
4747

4848
## 🤖 Compatibility with MeiliSearch
4949

50-
This package only guarantees the compatibility with the [version v0.15.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.15.0).
50+
This package only guarantees the compatibility with the [version v0.16.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.16.0).
5151

5252
## ⚙️ Development Workflow and Contributing
5353

src/client.rs

+3-39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{errors::*, indexes::*, request::*};
22
use serde_json::{json, Value};
3-
use serde::{Serialize, Deserialize};
3+
use serde::{Deserialize};
44
use std::collections::HashMap;
55

66
/// The top-level struct of the SDK, representing a client containing [indexes](../indexes/struct.Index.html).
@@ -186,7 +186,7 @@ impl<'a> Client<'a> {
186186
/// # async fn main() {
187187
/// let client = Client::new("http://localhost:7700", "masterKey");
188188
///
189-
/// match client.get_health().await {
189+
/// match client.health().await {
190190
/// Ok(()) => println!("server is operational"),
191191
/// Err(Error::MeiliSearchError { error_code: ErrorCode::Maintenance, .. }) => {
192192
/// eprintln!("server is in maintenance")
@@ -195,7 +195,7 @@ impl<'a> Client<'a> {
195195
/// }
196196
/// # }
197197
/// ```
198-
pub async fn get_health(&self) -> Result<(), Error> {
198+
pub async fn health(&self) -> Result<(), Error> {
199199
let r = request::<(), ()>(
200200
&format!("{}/health", self.host),
201201
self.apikey,
@@ -211,42 +211,6 @@ impl<'a> Client<'a> {
211211
}
212212
}
213213

214-
/// Update health of MeiliSearch server.
215-
///
216-
/// # Example
217-
///
218-
/// ```
219-
/// # use meilisearch_sdk::{client::*, indexes::*};
220-
/// #
221-
/// # #[tokio::main]
222-
/// # async fn main() {
223-
/// let client = Client::new("http://localhost:7700", "masterKey");
224-
///
225-
/// client.set_health(false).await.unwrap();
226-
/// # client.set_health(true).await.unwrap();
227-
/// # }
228-
/// ```
229-
pub async fn set_health(&self, health: bool) -> Result<(), Error> {
230-
#[derive(Debug, Serialize)]
231-
struct HealthBody {
232-
health: bool
233-
}
234-
235-
let r = request::<HealthBody, ()>(
236-
&format!("{}/health", self.host),
237-
self.apikey,
238-
Method::Put(HealthBody { health }),
239-
204,
240-
)
241-
.await;
242-
match r {
243-
// This shouldn't be an error; The status code is 200, but the request
244-
// function only supports one successful error code for some reason
245-
Err(Error::Empty) => Ok(()),
246-
e => e,
247-
}
248-
}
249-
250214
/// Get version of the MeiliSearch server.
251215
///
252216
/// # Example

src/errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum Error {
2121
/// The MeiliSearch server returned invalid JSON for a request.
2222
ParseError(serde_json::Error),
2323
/// An erroring status code, but no body
24-
// This is a hack to make Client::get_health work, since the request module
24+
// This is a hack to make Client::health work, since the request module
2525
// treats anything other than the expected status as an error. Since 204 is
2626
// specified, a successful status of 200 is treated as an error with an
2727
// empty body.
@@ -97,8 +97,7 @@ pub enum ErrorCode {
9797
InternalError,
9898
/// The provided token is invalid.
9999
InvalidToken,
100-
/// The MeiliSearch instance is under maintenance. You can set the maintenance
101-
/// state by using the `set_healthy` method of a Client.
100+
/// The MeiliSearch instance is under maintenance.
102101
Maintenance,
103102
/// The requested resources are protected with an API key, which was not
104103
/// provided in the request header.

0 commit comments

Comments
 (0)