BlackBird is a framework for Rust Tokio

Overview

BlackBird

BlackBird

Blackbird is framework like OTP for Erlang.

Blackbird is not a Actor Framewrok, it's Behavior for around Tokio task

This project currently provides the following functionality:

  • stage helper and behaviours for implementing producer and consumer stages (stream processing)

  • server many features for tokio task to implement standalone service with request/response api also support
    dynamic assign middleware for each service

  • metric a simple metric collector

  • web a web server send live state of tokio all task

Examples

Examples for Stage behaviors :

  • [ProducerConsumer] a stage between producer and consumer A -> ( B ) -> C

  • [Consumer] a subscriber to ProducerConsumer or Producer , Send demand get events and consume it

  • [Producer] a producer await on channel/mailbox take request with demand and reply a Vec of Event

Some Code :

pub struct HttpServer {
    ...
}

#[async_trait]
impl Server for HttpServer {
    pub async fn init(&mut self, uri: String, 
                      self_mailbox: Sender
   
    
     , 
                      RespPack
     
      >) -> GResult {
                    
        // here can do anything before listening on channel/mailbox
        ...

        // always must return Continue/Terminate(Reason)
        GResult::Continue
    }
    
    pub async fn handle_call(&mut self, req: 
      
       , from: oneshot::Sender
       
        
         >) -> GResult { // req is request message // we handle request and reply reply(from, RespPack::Message(...)); GResult::Continue } pub async fn handle_cast(&mut self, req: Request) -> GResult { // this is like handle_call but sender dont await for response // for example we retrun Terminate GResult::Terminate(Reason::Err("....".to_owned())) } // when we return GResult::Terminate, // internaly call terminate before shutdown pub async fn terminate(&mut self, reason: Reason) { ..... } } 
        
       
      
     
    
   

Running Httpserver


let (uri, sender_mailbox, _) = start_root_server("httpserver", // pass a name for generate uri for process
                  
                  Box::new(HttpServer{...}),
                  
                  5, // mailbox_size after reach to this, blocking caller with timeout 5ms

                  // we can define many middlewares to be called before req send to handle_cast/handle_call 
                  middlewares: vec![Box::new(|&mut request| ....),  
                                |&mut request| ....),
                                |&mut request| ....)],

                  // we can assign controller to get metric collector
                  controller: Some(sender_mailbox.clone()) 
                  ));

assert!( uri == "blackbird://server-httpserver )


// RequestPack is for build a request message 
let msg_pack = RequestPack::Message(...); 

// cast to server and not await on response
sender_mailbox.cast(Request::new(msg_pack)).await; 

License

Apache-2.0

You might also like...
First Git on Rust is reimplementation with rust in order to learn about rust, c and git.

First Git on Rust First Git on Rust is reimplementation with rust in order to learn about rust, c and git. Reference project This project refer to the

A stupid macro that compiles and executes Rust and spits the output directly into your Rust code

inline-rust This is a stupid macro inspired by inline-python that compiles and executes Rust and spits the output directly into your Rust code. There

Learn-rust - An in-depth resource to learn Rust 馃

Learning Rust 馃 Hello friend! 馃憢 Welcome to my "Learning Rust" repo, a home for my notes as I'm learning Rust. I'm structuring everything into lesson

A highly modular Bitcoin Lightning library written in Rust. Its Rust-Lightning, not Rusty's Lightning!

Rust-Lightning is a Bitcoin Lightning library written in Rust. The main crate, lightning, does not handle networking, persistence, or any other I/O. Thus, it is runtime-agnostic, but users must implement basic networking logic, chain interactions, and disk storage. More information is available in the About section.

Telegram bot help you to run Rust code in Telegram via Rust playground
Telegram bot help you to run Rust code in Telegram via Rust playground

RPG_BOT (Rust Playground Bot) Telegram bot help you to run Rust code in Telegram via Rust playground Bot interface The bot supports 3 straightforward

`Debug` in rust, but only supports valid rust syntax and outputs nicely formatted using pretty-please
`Debug` in rust, but only supports valid rust syntax and outputs nicely formatted using pretty-please

dbg-pls A Debug-like trait for rust that outputs properly formatted code Showcase Take the following code: let code = r#" [ "Hello, World!

Playing with web dev in Rust. This is a sample Rust microservice that can be deployed on Kubernetes.

Playing with web dev in Rust. This is a sample Rust microservice that can be deployed on Kubernetes.

馃悁 Building a federated alternative to reddit in rust

Lemmy A link aggregator / Reddit clone for the fediverse. Join Lemmy 路 Documentation 路 Report Bug 路 Request Feature 路 Releases 路 Code of Conduct About

Applied offensive security with Rust
Applied offensive security with Rust

Black Hat Rust - Early Access Deep dive into offensive security with the Rust programming language Buy the book now! Summary Whether in movies or main

Owner
DanyalMh
I'm preparing the next generation infrastructure for Heroad
DanyalMh
A Rust framework for building context-sensitive type conversion.

Xylem is a stateful type conversion framework for Rust.

Jonathan Chan Kwan Yin 4 May 11, 2022
Elegant, clean Rust development framework

Preview version, will not guarantee the stability of the API! Elegant, clean Rust development framework Core Features Relational database client for M

Ideal World 35 Dec 29, 2022
simple lottery maker made with rust, just web framework

Toy project for fun It's just for fun! making plausible lottery numbers for Korea made with rust This lottery web framework generates and presents pla

yacho (bakjuna) 4 Nov 24, 2023
鈿ustygram is a minimal and blazing fast telegram notification framework for Rust

鈿ustygram 鈿ustygram is a minimal and blazing fast telegram notification framework using Rust. Abstracts away the Telegram API complexity so your app

Chia Yong Kang 15 Dec 1, 2023
The 宄ㄧ湁 (EMei) JIT/AOT backend framework.

emei The 宄ㄧ湁 (EMei) JIT/AOT backend framework. Support Instructions x86_64 mov mov mov_zero_extend_bit8/16 mov_sign_extend_bit8/16/32 mov_rev movs(is m

Lyzh 14 Apr 11, 2022
Nimbus is a framework for building parachain consensus systems on cumulus-based parachains.

Cumulo -- Nimbus 鉀堬笍 Nimbus is a framework for building parachain consensus systems on cumulus-based parachains. Given the regular six-second pulse-lik

null 36 Dec 14, 2022
OptFrame is an optimization framework focused in metaheuristic techniques

optframe-rust Welcome to OptFrame project in Rust. What is OptFrame? OptFrame is an optimization framework focused in metaheuristic techniques, develo

OptFrame 4 Jan 30, 2022
Moonshine CSS - 馃 High-proof atomic CSS framework

Moonshine CSS - ?? High-proof atomic CSS framework

Econify 25 Nov 25, 2022
RustHunter is a modular incident response framework to build and compare environmental baselines

RustHunter is a modular incident response framework to build and compare environmental baselines. It is written in Rust and uses Ansible to collect data across multiple hosts.

Giovanni Pecoraro 13 Dec 12, 2022
Blazingly fast spam classification API built using Rocket Web Framework.

Telegram Antispam API Blazingly fast spam classification API built using Rocket Web Framework. Notes The classifier works in aggressive mode, it can s

Akshay Rajput 13 May 5, 2023