Crate avassa_client[][src]

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::ClientBuilder;

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

    // Use login using platform provided application token
    let approle_id = "secret approle id";
    let client = ClientBuilder::new()
        .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 = ClientBuilder::new()
        .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::ClientBuilder;

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

    // Use login using platform provided application token
    let approle_id = "secret approle id";
    let client = ClientBuilder::new()
        .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",
            Default::default())
            .await?;

        producer.produce(vec![1,2,3]).await?;
        Ok::<_, avassa_client::Error>(())
    });

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

    let (_metadata, message) = consumer.consume().await?;

    assert_eq!(message, vec![1,2,3]);
    Ok(())
}

Modules

volga

Library for producing and consuming Volga messages.

Structs

Client

The Client is used for all interaction with Control Tower or Edge Enforcer instances. Use one of the login functions to create an instance.

ClientBuilder

Builder for an Avassa Client

RESTError

Description of an error from the REST APIs

RESTErrorList

List of REST API error messages

Enums

Error

Error returned by client functions

Type Definitions

Result

Result type