Crates.io | reflux |
lib.rs | reflux |
version | |
source | src |
created_at | 2022-06-10 19:01:24.883525 |
updated_at | 2024-11-08 12:29:11.602951 |
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 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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 Sender
s.
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 Receiver
s 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.