Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Dec 9, 2024
1 parent 3c0fd3e commit 479e469
Showing 1 changed file with 134 additions and 0 deletions.
134 changes: 134 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,140 @@ This is not an AMQP 0-9-1 client (see [amqprs](https://github.com/gftea/amqprs))

This library is relatively young, breaking API changes are possible.

## Dependency

### Blocking Client

```toml
rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs", features = ["core", "blocking"] }
```

### Async Client

```toml
rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs", features = ["core", "async"] }
```

### Blocking Client with Tabled Support

```toml
rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs", features = ["core", "blocking", "tabled"] }
```

### Async CLient with Tabled Support

```toml
rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs", features = ["core", "async", "tabled"] }
```


## Usage

### Overview

This library offers two client implementations: a blocking one and an async one,
in `rabbitmq_http_client::blocking_api` and `rabbitmq_http_client::api`, respectively.

Both API versions and [`tabled`](https://docs.rs/tabled/latest/tabled/) support are optional features.

### Code Examples

Documentation for async API follows that of the blocking API.

### Blocking API

The examples below do not cover the entire API. Most ``

#### Instantiate a Client

```rust
use rabbitmq_http_client::blocking_api::ClientBuilder;

// a type alias for convenience
type APIClient<'a> = Client<&'a str, &'a str, &'a str>;

let endpoint = "http://localhost:15672/api";
let username = "username";
let password = "password";

let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

// list cluster nodes
let _ = rc.list_nodes();

// list user connections
let _ = rc.list_connections();

// fetch information and metrics of a specific queue
let _ = rc.get_queue_info("/", "qq.1");
```

#### List Cluster Nodes

```rust
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

let _ = rc.list_nodes();
```

#### List Client Connections

```rust
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

let _ = rc.list_connections();
```

#### Fetch Metrics of a Specific Queue or Stream

```rust
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

// fetch information and metrics of a specific queue or stream
let _ = rc.get_queue_info("/", "qq.1");
```

### Async API

#### Instantiate a Client

```rust
use rabbitmq_http_client::api::ClientBuilder;

// a type alias for convenience
type APIClient<'a> = Client<&'a str, &'a str, &'a str>;

let endpoint = "http://localhost:15672/api";
let username = "username";
let password = "password";
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();
```

#### List Cluster Members

```rust
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

rc.list_nodes().await;
```

#### List Client Connections

```rust
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

rc.list_connections().await;
```

#### Fetch Metrics of a Specific Queue or Stream

```rust
let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();

rc.get_queue_info("/", "qq.1").await;
```


## License

This crate, rabbitmq-http-api-client-rs, is dual-licensed under
Expand Down

0 comments on commit 479e469

Please sign in to comment.