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//! .application_login("https://api.customer.net", Some(approle_id)).await?;
19//!
20//! // Username and password authentication, good during the development phase
21//! let client = Client::builder()
22//! .add_root_certificate(&ca_cert)?
23//! .login("https://1.2.3.4", "joe", "secret").await?;
24//!
25//! Ok(())
26//! }
27//! ```
28//!
29//! ## Volga
30//! ### Create a Volga producer and consumer
31//! ```no_run
32//! #[tokio::main]
33//! async fn main() -> Result<(), avassa_client::Error> {
34//! use avassa_client::Client;
35//!
36//! // API CA certificate loaded
37//! let ca_cert = Vec::new();
38//!
39//! // Use login using platform provided application token
40//! let approle_id = "secret approle id";
41//! let client = Client::builder()
42//! .add_root_certificate(&ca_cert)?
43//! .application_login("https://api.customer.net", Some(approle_id)).await?;
44//!
45//! // Clone to move into async closure
46//! let producer_client = client.clone();
47//!
48//! tokio::spawn(async move {
49//! let mut producer = producer_client.volga_open_producer(
50//! "test-producer",
51//! "my-topic",
52//! avassa_client::volga::OnNoExists::Create(Default::default())
53//! )
54//! .await?;
55//!
56//! producer.produce(&serde_json::json!({
57//! "msg": "The Message",
58//! })).await?;
59//! Ok::<_, avassa_client::Error>(())
60//! });
61//!
62//! let mut consumer = client.volga_open_consumer(
63//! "test-consumer",
64//! "my-topic",
65//! Default::default())
66//! .await?;
67//!
68//! let message = consumer.consume::<String>().await?;
69//!
70//! assert_eq!(message.payload, "test message");
71//! Ok(())
72//! }
73//! ```
74
75#![deny(clippy::all)]
76#![warn(clippy::pedantic)]
77#![warn(clippy::cargo)]
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::*;