vertx-rust its a simple implementation of vert

The vertx-rust engine is based on tokio as a multi-threaded nonblocking event-driven engine

vertx-rust

Introduction

vertx-rust its a simple implementation of vert.x in Rust. The vertx-rust engine is based on crossbeam-channel and tokio as a multi-threaded nonblocking event-driven engine. Currently, the only implementation is the cluster version based on zookeeper as a cluster manager and standalone instance. In the future there will also be other implementations of the cluster manager

Features

  1. Nonblocking eventbus consumer | local_consumer
  2. Nonblocking eventbus request
  3. Nonblocking eventbus send
  4. Nonblocking eventbus publish
  5. Nonblocking multi-threaded tcp server - based on tokio
  6. Nonblocking multi-threaded http server - based on hyper
  7. Blocking and nonblocking simple hyper http client wrapper
  8. Zookeeper cluster manager

Benchmarks

Benchmarks on Dell G3 with Intel Core i7-8750H

Wrk benchmarks

Http server from no_cluster example:

wrk -d 90s -t 5 -c 500 http://127.0.0.1:9092/
Running 2m test @ http://127.0.0.1:9092/
  5 threads and 500 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.56ms    1.87ms  39.83ms   82.74%
    Req/Sec    40.29k     4.66k   63.80k    70.89%
  18022166 requests in 1.50m, 2.08GB read
Requests/sec: 200034.56
Transfer/sec:     23.66MB

Tcp server from no_cluster example:

wrk -d 90s -t 5 -c 500 http://127.0.0.1:9091/
Running 2m test @ http://127.0.0.1:9091/
  5 threads and 500 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.47ms    3.20ms  99.24ms   91.42%
    Req/Sec    50.67k     9.84k  105.72k    75.66%
  22653909 requests in 1.50m, 2.53GB read
Requests/sec: 251512.38
Transfer/sec:     28.78MB

Microbenchmarks

vertx_request           time:   [8.1251 us 8.1982 us 8.2809 us]                           
Found 7 outliers among 100 measurements (7.00%)
  5 (5.00%) high mild
  2 (2.00%) high severe

vertx_send              time:   [1.4308 us 1.4435 us 1.4594 us]                        
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) low severe
  2 (2.00%) low mild
  3 (3.00%) high severe

vertx_publish           time:   [1.8024 us 1.8305 us 1.8527 us]                           

serialize_message       time:   [203.27 ns 203.72 ns 204.20 ns]                              
Found 6 outliers among 100 measurements (6.00%)
  6 (6.00%) high mild

deserialize_message     time:   [145.16 ns 145.46 ns 145.79 ns]                                
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high severe

Work with vertx-rust

Code examples

Eventbus consumer

use vertx_rust::vertx::{VertxOptions, Vertx, NoClusterManager};

let vertx_options = VertxOptions::default();
let vertx : Vertx<NoClusterManager> = Vertx::new(vertx_options);
let event_bus = vertx.event_bus();

event_bus.consumer("test.01", move |m, _| {
  m.reply(..);
});

vertx.start();

Eventbus send

use vertx_rust::vertx::{VertxOptions, Vertx, NoClusterManager};

let vertx_options = VertxOptions::default();
let vertx : Vertx<NoClusterManager> = Vertx::new(vertx_options);
let event_bus = vertx.event_bus();

event_bus.send("test.01", Body::String("Hello World".to_string()));

Eventbus request

use vertx_rust::vertx::{VertxOptions, Vertx, NoClusterManager};

let vertx_options = VertxOptions::default();
let vertx : Vertx<NoClusterManager> = Vertx::new(vertx_options);
let event_bus = vertx.event_bus();

event_bus.request("test.01", Body::String("Hello World".to_string()), move |m, _| {
  ...
});

Tcp server

use vertx_rust::vertx::{VertxOptions, Vertx, NoClusterManager};
use vertx_rust::net::NetServer;

let vertx_options = VertxOptions::default();
let vertx : Vertx<NoClusterManager> = Vertx::new(vertx_options);
let event_bus = vertx.event_bus();

let net_server = NetServer::new(Some(event_bus.clone()));
net_server.listen(9091, move |_req, ev| {
  let mut resp = vec![];
  ...
  resp
});

vertx.start();

More examples on: examples

Issues

Collection of the latest Issues

kathog

kathog

0

Add support java vertx verticles:

  • standard - used event pool
  • worker - single thread
  • multi-thread worker - multi-thread worker pool
Versions

Find the latest versions by id

v0.3.0 - Dec 29, 2021

Change to async tokio engine

v0.2.2 - Apr 17, 2021

clean code for clippy and 2x fast serializable message

v0.2.1 - Mar 14, 2021

  • add helper function to body: c2db821

v0.2.0 - Mar 13, 2021

  • #7 from kathog/feature/#6_multi_types
  • remove unused dependencies
  • upgrade all dependencies to newest

v0.1.4 - Mar 13, 2021

use mimalloc as default memory allocator

v0.1.3 - Jan 12, 2021

  • #3 feature/#2_tls_support
  • remove serde::export from code
  • use std::marker::PhantomData

v0.1.2 - Jan 01, 2021

Fix reply message to event bus request to remote server

Information - Updated Jun 22, 2022

Stars: 9
Forks: 1
Issues: 2

Repositories & Extras

Example application and boiler plate code for Rust, Actix and Heroku

Actix is a popular Rust web framework and these examples get your feet wet

Example application and boiler plate code for Rust, Actix and Heroku

Pure rust based webgl with examples

This project is under heavily development, all api are very unstable until version 1.0 GA release

Pure rust based webgl with examples

rustlings 🦀❤️

Rust code examples to play around with

rustlings 🦀❤️

A vector graphics renderer using OpenGL with a Rust &amp; C API

A Rust example can be found in examples/quickstart

A vector graphics renderer using OpenGL with a Rust &amp; C API

Pure-rust implementation of multimedia primitives and eventually some examples of demuxers, muxers and codecs

The code is still in flux and the API is getting slowly fleshed out, please

Pure-rust implementation of multimedia primitives and eventually some examples of demuxers, muxers and codecs

This is a small Rust Crate for AnyBar

This is a small Rust Crate for documentation for more examples and details on certain functions

This is a small Rust Crate for AnyBar

Rust-AV examples

A series of some multimedia examples

Rust-AV examples

Unsafe Rust bindings for the Metal 3D Graphics API

The examples directory highlights different ways of using the Metal graphics API for rendering

Unsafe Rust bindings for the Metal 3D Graphics API

Yet another learn by example with rust

More examples of rust usage are welcome, so feel free to create PRs to help me to make this repo better

Yet another learn by example with rust

Rust WASM Web Worker Examples

This repository contains four different examples of using web workers in conjunction with WASM in

Rust WASM Web Worker Examples

Luno Rust API Wrapper 🦀🚀

Examples of calls can be found in the examples/ directory

Luno Rust API Wrapper 🦀🚀
Facebook Instagram Twitter GitHub Dribbble
Privacy