avassa_client/lib.rs
1//!
2//! Library for interacting with an Avassa system.
3//!
4//! ## Avassa Client
5//! The first interaction is to login into the system
6//! ```no_run
7//! #[tokio::main]
8//! async fn main() -> Result<(), avassa_client::Error> {
9//! use avassa_client::Client;
10//!
11//! // API CA certificate loaded
12//! let ca_cert = Vec::new();
13//!
14//! // Use login using platform provided application token
15//! let approle_id = "secret approle id";
16//! let client = Client::builder()
17//! .add_root_certificate(&ca_cert)?
18//! .approle_login("https://api.customer.net",
19//! &std::env::var("APPROLE_SECRET_ID").unwrap(),
20//! Some(approle_id)).await?;
21//!
22//! // Username and password authentication, good during the development phase
23//! let client = Client::builder()
24//! .add_root_certificate(&ca_cert)?
25//! .login("https://1.2.3.4", "joe", "secret").await?;
26//!
27//! Ok(())
28//! }
29//! ```
30//!
31//! ## Volga
32//! ### Create a Volga producer and consumer
33//! ```no_run
34//! #[tokio::main]
35//! async fn main() -> Result<(), avassa_client::Error> {
36//! use avassa_client::Client;
37//!
38//! // API CA certificate loaded
39//! let ca_cert = Vec::new();
40//!
41//! // Use login using platform provided application token
42//! let approle_id = "secret approle id";
43//! let client = Client::builder()
44//! .add_root_certificate(&ca_cert)?
45//! .application_login("https://api.customer.net", Some(approle_id)).await?;
46//!
47//! // Clone to move into async closure
48//! let producer_client = client.clone();
49//!
50//! tokio::spawn(async move {
51//! let mut producer = producer_client.volga_open_producer(
52//! "test-producer",
53//! "my-topic",
54//! avassa_client::volga::OnNoExists::Create(Default::default())
55//! )
56//! .await?;
57//!
58//! producer.produce(&serde_json::json!({
59//! "msg": "The Message",
60//! })).await?;
61//! Ok::<_, avassa_client::Error>(())
62//! });
63//!
64//! let mut consumer = client.volga_open_consumer(
65//! "test-consumer",
66//! "my-topic",
67//! Default::default())
68//! .await?;
69//!
70//! let message = consumer.consume::<String>().await?;
71//!
72//! assert_eq!(message.payload, "test message");
73//! Ok(())
74//! }
75//! ```
76
77#![warn(clippy::pedantic)]
78#![allow(clippy::missing_errors_doc)]
79
80
81#[cfg(feature = "utilities")]
82pub mod utilities;
83
84#[cfg(feature = "login-helper")]
85pub mod login_helper;
86
87#[cfg(feature = "supctl")]
88pub mod supctl;
89
90mod error;
91pub use error::*;
92
93#[cfg(feature = "client")]
94mod client;
95#[cfg(feature = "client")]
96pub mod strongbox;
97#[cfg(feature = "client")]
98pub mod volga;
99
100#[cfg(feature = "client")]
101pub use client::*;