| Crates.io | reflux |
| lib.rs | reflux |
| version | 6.4.2 |
| created_at | 2022-06-10 19:01:24.883525+00 |
| updated_at | 2025-04-01 09:06:04.516174+00 |
| description | A microservice framework aimed at scalability, flexibility and ease of use |
| homepage | https://github.com/kyleb000/reflux/wiki |
| repository | https://github.com/kyleb000/reflux |
| max_upload_size | |
| id | 603722 |
| size | 82,886 |
Reflux is a cutting-edge Rust framework designed to streamline the development of microservices with a focus on scalability, flexibility, and usability. By leveraging Rust's performance and safety features, Reflux empowers developers to build robust, high-performance microservices that can seamlessly adapt to evolving business needs. Whether you're scaling up to handle millions of requests or integrating diverse service components, Reflux provides the tools and framework you need to achieve efficient and maintainable microservice architectures. Dive into Reflux and transform the way you build and manage microservices with ease and confidence.
In Reflux, there are various object types that are available.
The Extractor is responsible for reading data from an external source (such as a file or socket connection) and yielding data extracted from the source.
When using coroutines in the Extractor, there are two valid methods of yielding data:
#[coroutine] || {
loop {
yield 1
}
}
This method is useful if you are reading from a constant stream of data, such a socket.
#[coroutine] || {
yield 1
}
This method is useful if you are reading from a data source one time, such as reading data from a file.
The Transformer is responsible for mutating data. A transformer can convert data from one type to another, or mutate data, but keep the type.
The transformer has three behaviours, represented by the following enum:
enum TransformerResult<O, T, E> {
Transformed(T),
NeedsMoreWork(O),
Error(E),
}
Transformed: The Transformer has completed work on the data. This will pass the data along a Reflux pipeline.NeedsMoreWork - The Transformer needs to do more work on the data. Data are fed back into the Transformer for further processing. This behaviour is useful for recursive functions, such as walking through a directory tree.Error - The Transformer encountered an error whilst processing the data.Note: As of version 1.2.0, the Transformer error handler simply prints the error to stderr.
There may be instances when you may want to yield data as you are iterating through an iterable. If you are yielding in the for loop, the borrow checker will prevent compilation.
For example, the following code snippet will not compile:
#[coroutine] || {
let vals = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for i in vals.iter() {
if *i == 6 {
yield *i;
}
}
}
However, you can still achieve this behaviour and satisfy the borrow checker using the following technique:
#[coroutine] || {
let vals = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let mut res = None;
for i in vals {
if *i == 6 {
res = Some(*i);
break;
}
}
yield res.unwrap()
}
The Balancer is responsible for routing data amongst a set of Receiver s in a Round Robin fasion.
The Filter is responsible for conditionally allowing data to flow through a Reflux pipeline. A predicate is supplied to a Filter and if data satisfies the predicate, it may pass through.
Use a pure function as a predicate with a complexity of O(1), if at all possible. Functions with a higher complexity, or that read data from a file or socket have the potential to prevent the predicate from completing execution, either through an error or an infitite loop.
However, for use cases such as spam filters, it may be impossible to avoid using predicates that read from data sources, or with non-constant time complexities.
The Broadcast is responsible for broadcasting data to multiple Senders.
The Funnel is responsible for collecting data from multiple Receiver s and sending the data through to a single Sender.
The Funnel can potentially be a bottleneck in a Reflux pipeline, causing uncontrolled memory usage. It is advised to connect a small number of Receivers to a Funnel.
The Messenger is responsible for receiving messages and passing it through to the relevant Sender.
The Loader is the end of a Reflux pipeline. A loader can drop data, or write it to an external source (such as a file or socket).
Due to coroutines being an unstable feature in Rust, and the evolving development of Reflux, the framework is currently unstable and is subject to change in the future.