28 releases

new 0.5.3 Jan 17, 2025
0.5.1 Aug 26, 2024
0.5.0 Nov 13, 2023
0.4.3 Jun 21, 2023
0.1.0 Jan 8, 2021

#494 in Web programming

Download history 43/week @ 2024-09-25 2/week @ 2024-10-09 2/week @ 2024-10-16 3/week @ 2024-10-30 4/week @ 2024-11-06 1/week @ 2024-11-13 2/week @ 2024-11-20 1/week @ 2024-12-04 3/week @ 2024-12-11 137/week @ 2025-01-08

137 downloads per month

Apache-2.0

85KB
2K SLoC

Avassa logo

Avassa Client Library

Use this library to integrate with the Avassa APIs. For documentation, please see the docs.

For more information on Avassa, please see here.


lib.rs:

Library for interacting with an Avassa system.

Avassa Client

The first interaction is to login into the system

#[tokio::main]
async fn main() -> Result<(), avassa_client::Error> {
    use avassa_client::Client;

    // API CA certificate loaded
    let ca_cert = Vec::new();

    // Use login using platform provided application token
    let approle_id = "secret approle id";
    let client = Client::builder()
        .add_root_certificate(&ca_cert)?
        .application_login("https://api.customer.net", Some(approle_id)).await?;

    // Username and password authentication, good during the development phase
    let client = Client::builder()
        .add_root_certificate(&ca_cert)?
        .login("https://1.2.3.4", "joe", "secret").await?;

    Ok(())
}

Volga

Create a Volga producer and consumer

#[tokio::main]
async fn main() -> Result<(), avassa_client::Error> {
    use avassa_client::Client;

    // API CA certificate loaded
    let ca_cert = Vec::new();

    // Use login using platform provided application token
    let approle_id = "secret approle id";
    let client = Client::builder()
        .add_root_certificate(&ca_cert)?
        .application_login("https://api.customer.net", Some(approle_id)).await?;

    // Clone to move into async closure
    let producer_client = client.clone();

    tokio::spawn(async move {
        let mut producer = producer_client.volga_open_producer(
            "test-producer",
            "my-topic",
            avassa_client::volga::OnNoExists::Create(Default::default())
            )
            .await?;

        producer.produce(&serde_json::json!({
           "msg": "The Message",
        })).await?;
        Ok::<_, avassa_client::Error>(())
    });

    let mut consumer = client.volga_open_consumer(
        "test-consumer",
        "my-topic",
        Default::default())
        .await?;

    let message = consumer.consume::<String>().await?;

    assert_eq!(message.payload, "test message");
    Ok(())
}

Dependencies

~16–29MB
~504K SLoC