Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: v0.38.0 and qdrant page #257

Merged
merged 6 commits into from
Feb 1, 2024
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
2 changes: 1 addition & 1 deletion configuration/shuttle-versions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Combining all of the above, these are the recommended steps for upgrading a Shut

2. Update your project's `shuttle-...` dependencies in `Cargo.toml`:
```toml Cargo.toml
shuttle-runtime = "0.37.0"
shuttle-runtime = "0.38.0"
# etc
```

Expand Down
6 changes: 3 additions & 3 deletions examples/actix-postgres.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ edition = "2021"

[dependencies]
actix-web = "4.3.1"
shuttle-actix-web = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-actix-web = "0.38.0"
shuttle-runtime = "0.38.0"
serde = "1.0.148"
shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] }
shuttle-shared-db = { version = "0.38.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/actix-websocket-actorless.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ futures = "0.3"
reqwest = "0.11"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shuttle-actix-web = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-actix-web = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = { version = "1", features = ["rt-multi-thread", "sync"] }
tracing = "0.1"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/actix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ edition = "2021"

[dependencies]
actix-web = "4.3.1"
shuttle-actix-web = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-actix-web = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.26.0"
```
</CodeGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/axum-jwt-authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ jsonwebtoken = "8.3.0"
once_cell = "1.18.0"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
shuttle-axum = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-axum = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.28.2"
tracing-subscriber = "0.3.17"
```
Expand Down
6 changes: 3 additions & 3 deletions examples/axum-postgres.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ edition = "2021"
[dependencies]
axum = "0.7.3"
serde = { version = "1.0.188", features = ["derive"] }
shuttle-axum = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] }
shuttle-axum = "0.38.0"
shuttle-runtime = "0.38.0"
shuttle-shared-db = { version = "0.38.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.28.2"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/axum-static-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ publish = false

[dependencies]
axum = "0.7.3"
shuttle-axum = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-axum = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.28.2"
tower-http = { version = "0.5.0", features = ["fs"] }
```
Expand Down
4 changes: 2 additions & 2 deletions examples/axum-websockets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ futures = "0.3.28"
reqwest = "0.11.23"
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96"
shuttle-axum = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-axum = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.28.2"
tower-http = { version = "0.5.0", features = ["fs"] }
```
Expand Down
4 changes: 2 additions & 2 deletions examples/axum.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ edition = "2021"

[dependencies]
axum = "0.7.3"
shuttle-axum = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-axum = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.28.2"
```
</CodeGroup>
Expand Down
6 changes: 3 additions & 3 deletions examples/poise.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ publish = false
[dependencies]
anyhow = "1.0.68"
poise = "0.6.1"
shuttle-runtime = "0.37.0"
shuttle-secrets = "0.37.0"
shuttle-runtime = "0.38.0"
shuttle-secrets = "0.38.0"
# Since poise is a serenity command framework, it can run on Shuttle with shuttle-serenity
shuttle-serenity = "0.37.0"
shuttle-serenity = "0.38.0"
tracing = "0.1.37"
tokio = "1.26.0"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/rocket-jwt-authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jsonwebtoken = { version = "8.1.1", default-features = false }
lazy_static = "1.4.0"
rocket = { version = "0.5.0", features = ["json"] }
serde = { version = "1.0.148", features = ["derive"] }
shuttle-rocket = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-rocket = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.26.0"
```
Your `main.rs` should look like this:
Expand Down
6 changes: 3 additions & 3 deletions examples/rocket-postgres.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ edition = "2021"
[dependencies]
rocket = { version = "0.5.0", features = ["json"] }
serde = "1.0.148"
shuttle-rocket = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] }
shuttle-rocket = "0.38.0"
shuttle-runtime = "0.38.0"
shuttle-shared-db = { version = "0.38.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/rocket-static-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ publish = false

[dependencies]
rocket = "0.5.0"
shuttle-rocket = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-rocket = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.26.0"
```

Expand Down
4 changes: 2 additions & 2 deletions examples/rocket.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ edition = "2021"

[dependencies]
rocket = "0.5.0"
shuttle-rocket = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-rocket = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.26.0"
```
</CodeGroup>
Expand Down
8 changes: 4 additions & 4 deletions examples/serenity-todo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ edition = "2021"
anyhow = "1.0.66"
serde = "1.0.148"
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
shuttle-runtime = "0.37.0"
shuttle-secrets = "0.37.0"
shuttle-serenity = "0.37.0"
shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] }
shuttle-runtime = "0.38.0"
shuttle-secrets = "0.38.0"
shuttle-serenity = "0.38.0"
shuttle-shared-db = { version = "0.38.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
tracing = "0.1.37"
Expand Down
6 changes: 3 additions & 3 deletions examples/serenity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ edition = "2021"
[dependencies]
anyhow = "1.0.66"
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
shuttle-runtime = "0.37.0"
shuttle-secrets = "0.37.0"
shuttle-serenity = "0.37.0"
shuttle-runtime = "0.38.0"
shuttle-secrets = "0.38.0"
shuttle-serenity = "0.38.0"
tokio = "1.26.0"
tracing = "0.1.37"
```
Expand Down
2 changes: 1 addition & 1 deletion examples/shuttle-next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ edition = "2021"
crate-type = [ "cdylib" ]

[dependencies]
shuttle-next = "0.37.0"
shuttle-next = "0.38.0"
```

Using the `shuttle-next::app!` macro, we can create HTTP API endpoints, setting the
Expand Down
2 changes: 1 addition & 1 deletion getting-started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Although a bit slower, you can also install directly with cargo:
cargo install cargo-shuttle
```

<Note>Installing cargo-shuttle from source requires Rust 1.70+. You can verify by running `cargo --version`.</Note>
<Note>Installing cargo-shuttle from source requires Rust 1.75+. You can verify by running `cargo --version`.</Note>

### Arch Linux

Expand Down
3 changes: 2 additions & 1 deletion mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"resources/shuttle-aws-rds",
"resources/shuttle-shared-db",
"resources/shuttle-persist",
"resources/shuttle-turso"
"resources/shuttle-turso",
"resources/shuttle-qdrant"
]
},
"resources/shuttle-secrets",
Expand Down
6 changes: 3 additions & 3 deletions resources/custom-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ edition = "2021"
async-trait = "0.1.56"
axum = "0.7.3"
serde = { version = "1.0.148", default-features = false, features = ["derive"] }
shuttle-service = "0.37.0"
shuttle-axum = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-service = "0.38.0"
shuttle-axum = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.28.2"
```
</CodeGroup>
19 changes: 10 additions & 9 deletions resources/shuttle-persist.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ title: "Shuttle Persist"
icon: "database"
---

The persist plugin allows data to be persisted in a key-value store, which is backed by a struct type. The struct implements `serde::Serialize` for serialization (prepare data for saving or transmission) and `serde::Deserialize` for deserialization (load data to memory, either from storage or fetched via the network). The persist plugin is useful for saving and retrieving data when it is not desired to hard code that data into the app. An example is saved settings for a Discord bot that need to remain the same between updates. State data, used in web frameworks such as Axum and Rocket, is also a good candidate for use of the persist plugin.
<Warning>The long-term goal is to deprecate and replace Shuttle Persist with more sophisticated key-value or blob storage solutions. When that happens, migrating saved Persist data to the new services will be possible.</Warning>

The persist plugin allows anything that implements `serde::Serialize` and `serde::Deserialize` to be persisted in a key-value store on the filesystem, and persist between deployments. This is useful for saving and retrieving data when it is not desired to hard code that data into the app. An example is saved settings for a Discord bot that need to remain the same between updates. State data, used in web frameworks such as Axum and Rocket, is also a good candidate for use of the persist plugin.

## Usage

To use the persist plugin, add `shuttle-persist` to the dependencies of your service with `cargo add shuttle-persist`. Then, annotate your `shuttle_runtime::main` function by adding the `shuttle-persist::Persist` attribute as a parameter. This will give a `PersistInstance`. There are six methods available to `PersistInstance`, providing tools to manage the data stored within. The methods are:
To use the persist plugin, add `shuttle-persist` to the dependencies of your service with `cargo add shuttle-persist`. Then, annotate your `shuttle_runtime::main` function by adding the `shuttle-persist::Persist` attribute as a parameter. This will give a `PersistInstance`. The methods available are:

- `clear()`: removes the keys within the `PersistInstance`
- `list()`: returns a vector of strings containing all the keys associated with a `PersistInstance`
- `load()`: loads a value from a key stored within the `PersistInstance`
- `new()`: constructs a new `PersistInstance` along with its associated storage folder
- `save()`: saves a key-value pair into the `PersistInstance`
- `remove()`: deletes a key from the `PersistInstance`
- `save()`: saves a key-value pair
- `load()`: loads the value stored in a key
- `remove()`: deletes a key
- `list()`: returns all the keys as a vector of strings
- `clear()`: deletes all keys

## Example

This snippet shows a Shuttle rocket main function that uses the `shuttle_persist::Persist` attribute to provision and get access to a `PersistInstance`. In this example,the `PersistInstance` is used to store state for the app.
This snippet shows a Shuttle rocket main function that uses the `shuttle_persist::Persist` attribute to provision and get access to a `PersistInstance`. In this example, the `PersistInstance` is used to store state for the app.

```rust main.rs
#[shuttle_runtime::main]
Expand Down
50 changes: 50 additions & 0 deletions resources/shuttle-qdrant.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "Shuttle Qdrant"
icon: "database"
---

This plugin allows services to connect to a [Qdrant](https://qdrant.tech/) database. Qdrant is a vector database & vector similarity search engine.

You can get started in seconds by cloning our Axum + Qdrant example with

```bash
cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder axum/qdrant
```

## Usage

<Note>**IMPORTANT:** Currently Shuttle isn't able to provision a Qdrant Cloud cluster for you (yet). This means you will have to create an account on their [website](https://qdrant.tech/) and follow the few steps required to create a cluster and an API key to access it.</Note>

Add `shuttle-qdrant` and `qdrant-client` to the dependencies for your service by running `cargo add shuttle-qdrant qdrant-client@1.7.0`. This resource will be provided by adding the `shuttle_qdrant::Qdrant` attribute to your Shuttle main function.

It returns a `qdrant_client::QdrantClient`. When running locally it will by default spin up a Qdrant Docker container for your project.

If you want to connect to a remote database when running locally, you can specify the `local_url` parameter.

### Parameters

| Parameter | Type | Required? | Description |
| ---------- | ------ | --------- | ----------- |
| cloud_url | &str | In deployment | URL of the database to connect to. NOTE: It should use the gRPC port. |
| api_key | &str | No | Required if the database requires an API key. |
| local_addr | &str | No | If specified, connect to this URL on local runs instead of using a Docker container. |

<Warning>Make sure the `cloud_url` parameter is specifying the gRPC port of the database. This is typically done by adding `:6334` at the end.</Warning>

You can use secrets interpolation to set the URL and API key. See below for an example.

### Example

In the case of an Axum server, your main function can look like this:

```rust
use qdrant_client::prelude::*;

#[shuttle_runtime::main]
async fn axum(
#[shuttle_qdrant::Qdrant(cloud_url = "{secrets.CLOUD_URL}", api_key = "{secrets.API_KEY}")]
qdrant: QdrantClient,
) -> shuttle_axum::ShuttleAxum {
// set up state and router...
}
```
2 changes: 1 addition & 1 deletion shuttle-next/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ edition = "2021"
crate-type = [ "cdylib" ]

[dependencies]
shuttle-next = "0.37.0"
shuttle-next = "0.38.0"
```

Using the `shuttle-next::app!` macro, we can create HTTP API endpoints, setting the
Expand Down
4 changes: 2 additions & 2 deletions tutorials/custom-service.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ axum = "0.6.4"
hyper = "0.14.24"
poise = "0.5.2"
serde = "1.0"
shuttle-runtime = "0.37.0"
shuttle-secrets = "0.37.0"
shuttle-runtime = "0.38.0"
shuttle-secrets = "0.38.0"
tokio = "1.26.0"
```

Expand Down
8 changes: 4 additions & 4 deletions tutorials/url-shortener.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ edition = "2021"

[dependencies]
rocket = "0.5.0"
shuttle-rocket = "0.37.0"
shuttle-runtime = "0.37.0"
shuttle-rocket = "0.38.0"
shuttle-runtime = "0.38.0"
tokio = "1.26.0"
```

Expand All @@ -152,8 +152,8 @@ $ cargo shuttle deploy
Compiling rocket_http v0.5.0
Compiling rocket_codegen v0.5.0
Compiling rocket v0.5.0
Compiling shuttle-rocket v0.37.0
Compiling shuttle-runtime v0.37.0
Compiling shuttle-rocket v0.38.0
Compiling shuttle-runtime v0.38.0
Compiling url-shortener v0.1.0 (/opt/shuttle/crates/url-shortener)
Finished dev [unoptimized + debuginfo] target(s) in 1m 01s

Expand Down
8 changes: 4 additions & 4 deletions tutorials/websocket-chat-app-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ hyper = { version = "0.14", features = ["client", "http2"] }
hyper-tls = "0.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shuttle-axum = { version = "0.37.0" }
shuttle-runtime = { version = "0.37.0" }
shuttle-secrets = "0.37.0"
shuttle-static-folder = "0.37.0"
shuttle-axum = { version = "0.38.0" }
shuttle-runtime = { version = "0.38.0" }
shuttle-secrets = "0.38.0"
shuttle-static-folder = "0.38.0"
sync_wrapper = "0.1"
tokio = { version = "1", features = ["full"] }
tower-http = { version = "0.3.5", features = ["fs", "auth"]}
Expand Down
Loading