Skip to content

Commit e75a45a

Browse files
committed
0.1.3-beta
1 parent 6f3e8fa commit e75a45a

File tree

13 files changed

+87
-30
lines changed

13 files changed

+87
-30
lines changed

CARGO.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Rabbit-Borough
2+
3+
## A rabbit MQ abstraction build upon [Lapin](https://crates.io/crates/lapin/1.0.2)
4+
5+
## Example
6+
7+
``` Rust
8+
fn main() {
9+
let config: JSONConfiguration = configuration::reader::read("./config.json").unwrap();
10+
println!("[{}] - Configuration read", line!(),);
11+
12+
LocalPool::new().run_until(async {
13+
consume(&config, &handler).await;
14+
})
15+
}
16+
17+
fn handler(_delivery: &Delivery) -> HandleMessageResult {
18+
// In order to read the message you need to convert the _delivery.data from a u8 vec to a utf8 string :
19+
// std::str::from_utf8(&_delivery.data))
20+
return HandleMessageResult::Ack;
21+
}
22+
```
23+
24+
## Idea
25+
26+
The whole idea is basically to be able to create a consumer project with minimal effort, by bypassing templating, configuration and complicated resiliency logic.
27+
28+
But most of the modules are public in this abstraction, so as to left some breathing space for custom composing.
29+
30+
## Thoughts
31+
Given that I use rabbitMq daily in nearly every application, this mini library is something that I might benefit in the near future. Luckily someone could find similar benefit as well.

CHANGELOG.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1+
### 0.1.3-beta
12

2-
### 0.1.2
3+
#### Breaking changes
4+
5+
* Renamed handler_message_result to handle_message_result as it was an annoying typo
6+
7+
#### Bug fixes and general improvements
8+
9+
* Added better descriptions in documentation
10+
* Went through some manual e2e resiliency testing.
11+
12+
### 0.1.2-alpha
313

414
* Added unit tests
515
* Converted the project structure to a lib
616
* If the configuration file cannot be read, use the default values
717
* Removing some logs and replacing them with proper error handling and error propagation
818
* Added Connection resiliency. If the RabbitMq dies, it will start retrying to connect until it exhausts all retries
919

10-
### 0.1.1
20+
### 0.1.1-alpha
1121

1222
* added default on JSONConfiguration
1323
* added DeclareProperties, so as to choose which action should be performed during setup (default to true)
1424
* removed ConsumerConfiguration, as it was considered duplication
1525
* abstracted consumer
1626

17-
### 0.1.0
27+
### 0.1.0-alpha
1828

1929
* updated to Lapin v1.0.0
2030
* added default implementation for JSONConfiguration properties
2131
* connection retry config
22-
* added ConsumerConfiguration, ConnectionProperties and BindingProperties
32+
* added ConsumerConfiguration, ConnectionProperties and BindingProperties

Cargo.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
[package]
22
name = "rabbit_borough"
3-
version = "0.1.2-alpha"
3+
version = "0.1.3-beta"
44
authors = ["stefanos.kouroupis <manekato@gmail.com>"]
55
edition = "2018"
66
description = "Create a RabbitMQ consumer project with minimal effort, by bypassing templating, configuration and complicated resiliency logic"
7-
readme = "README.md"
7+
readme = "CARGO.md"
88
repository = "https://github.com/elasticrash/rabbit-borough"
99
license = "MIT"
10-
license-file = "LICENSE"
1110
keywords = ["rabbitmq", "amqp"]
1211

1312
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1413
[dependencies]
15-
lapin = "1.0.0"
14+
lapin = "1.0.2"
1615
futures-executor = "0.3.5"
1716
futures = "0.3.5"
1817
serde = "1.0.110"

examples/consumer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use lapin::message::Delivery;
55
use rabbit_borough::configuration;
66
use rabbit_borough::configuration::config_model::JSONConfiguration;
77
use rabbit_borough::consumer::consumer::consume;
8-
use rabbit_borough::consumer::handler_message_result::HandleMessageResult;
8+
use rabbit_borough::consumer::handle_message_result::HandleMessageResult;
99

1010
fn main() {
1111
let config: JSONConfiguration = configuration::reader::read("./config.json").unwrap();

src/configuration/config_model.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use serde::Deserialize;
22

3+
/// Top level configuration class
34
#[serde(default)]
45
#[derive(Deserialize, Clone, Debug, PartialEq)]
56
pub struct JSONConfiguration {
@@ -8,6 +9,7 @@ pub struct JSONConfiguration {
89
pub declare: DeclareProperties,
910
}
1011

12+
/// All the properties required for creating a connection
1113
#[serde(default)]
1214
#[derive(Deserialize, Clone, Debug, PartialEq)]
1315
pub struct ConnectionProperties {
@@ -21,6 +23,7 @@ pub struct ConnectionProperties {
2123
pub retry: u64,
2224
}
2325

26+
/// Configuration for binding an Queue to an Exchange
2427
#[serde(default)]
2528
#[derive(Deserialize, Clone, Debug, PartialEq)]
2629
pub struct BindingProperties {
@@ -29,6 +32,7 @@ pub struct BindingProperties {
2932
pub routing_key: String,
3033
}
3134

35+
/// Configuration on whether some setup should be deemed unnecessary
3236
#[serde(default)]
3337
#[derive(Deserialize, Clone, Debug, PartialEq)]
3438
pub struct DeclareProperties {

src/configuration/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
/// Module for reading or getting default configuration
12
pub mod reader;
3+
/// This module only contains the structs needed for the configuration
24
pub mod config_model;

src/configuration/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::Read;
55
use std::path::Path;
66

77
/**
8-
* ## Read configuration from config.json
8+
* ## Reads configuration from provided file
99
* If file does not exist or we cannot read the content of the file,
1010
* we use the default values
1111
*/

src/consumer/connection_manager.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub struct GetConnectionError {
88
pub last_reason: lapin::Error,
99
}
1010

11-
#[allow(dead_code)]
1211
#[derive(Debug)]
1312
pub enum ConnectionState {
1413
MaximumConnectionRetriesReached,

src/consumer/consumer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::configuration::config_model::JSONConfiguration;
2-
use crate::consumer::handler_message_result::action_result;
3-
use crate::consumer::handler_message_result::HandleMessageResult;
2+
use crate::consumer::handle_message_result::action_result;
3+
use crate::consumer::handle_message_result::HandleMessageResult;
44
use crate::consumer::setup::setup_consumer;
55
use lapin::message::Delivery;
66
use lapin::options::BasicConsumeOptions;

0 commit comments

Comments
 (0)