8 releases (4 breaking)

0.5.1 Jun 25, 2024
0.5.0 Sep 19, 2023
0.4.0 Sep 13, 2023
0.3.0 Sep 13, 2023
0.1.2 Sep 11, 2023

#1455 in Web programming

Download history 29/week @ 2024-07-24 8/week @ 2024-07-31 6/week @ 2024-09-11 9/week @ 2024-09-18 11/week @ 2024-09-25

403 downloads per month

MIT license

39KB
632 lines

qstash-rs 🦀: Upstash QStash SDK for Rust

Crates.io

About

qstash-rs is a Rust library for interacting with Upstash QStash. It contains a client and a server (WIP) module. The client library it is a wrapper around the Upstash QStash REST API.

Installation

You can install qstash-rs with cargo:

cargo add qstash-rs

Client Usage

To start using the client SDK, you need to instantiate the Client struct with your QStash token:

#[tokio::main]
async fn main() {
  let qstash_client = Client::new("<QSTASH_TOKEN>", None, None).expect("Could not create client");
}

Then you can access any of the methods that the client supports. For example to publish a new message with a JSON body to a queue:

#[tokio::main]
async fn main() {
    let qstash_client = Client::new("<QSTASH_TOKEN>", None, None).expect("Could not create client");

    match qstash_client
        .publish_json(
            PublishRequestUrl::Url("https://google.com".parse().expect("Could not parse URL")),
            HashMap::from([("test", "test")]),
            None,
        )
        .await
    {
        Ok(r) => {
            tracing::info!("Response: {:?}", r);
            for res in r {
                if res.error.is_some() {
                    panic!("This should NOT have an error");
                }
            }
        }
        Err(e) => {
            tracing::error!("{}", e.to_string());
            panic!("Could not publish");
        }
    };
}

A more comprehensive example can be found in the crate documentation

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue if you have a problem, question, or suggestion.

License

This project operates under the MIT License. Details in the LICENSE file.

Dependencies

~5–16MB
~199K SLoC