Skip to content

Commit

Permalink
switch default client to async (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz authored Nov 24, 2022
1 parent af05afa commit bb44993
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 59 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gorse_rs"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
description = "Rust SDK for gorse recommender system"
readme = "README.md"
Expand All @@ -18,3 +18,4 @@ serde_json = "1.0"
[dev-dependencies]
chrono = "0.4.23"
redis = "0.22.1"
tokio = { version = "1.22.0", features = ["macros"] }
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Rust SDK for gorse recommender system

```toml
[dependencies]
gorse_rs = "0.4.0"
gorse_rs = "0.4.1"
```

## Usage

- Use async client:

```rust
use gorse_rs::{Feedback, Gorse};

Expand All @@ -30,3 +32,23 @@ client.insert_feedback(&feedback);

client.get_recommend("100");
```

- Use blocking client:

```rust
use gorse_rs::Feedback;
use gorse_rs::blocking::Gorse;

let client = Gorse::new("http://127.0.0.1:8087", "api_key");

let feedback = vec![
Feedback::new("star", "bob", "vuejs:vue", "2022-02-24"),
Feedback::new("star", "bob", "d3:d3", "2022-02-25"),
Feedback::new("star", "bob", "dogfalo:materialize", "2022-02-26"),
Feedback::new("star", "bob", "mozilla:pdf.js", "2022-02-27"),
Feedback::new("star", "bob", "moment:moment", "2022-02-28")
];
client.insert_feedback(&feedback).await;

client.get_recommend("100").await;
```
Loading

0 comments on commit bb44993

Please sign in to comment.