Giter Club home page Giter Club logo

bastion's Introduction



Bastion: Fault-tolerant Runtime for Rust applications

The breeze of the cold winter had come. This time of the year, Crashers arrive in the village. These are the giants who can't be evaded. They born to destroy and take people to the Paniks Heights. Suddenly, The developer descried the blurry silhouettes of Crashers from afar.

With cold and cracked voice, he whispered:

It is time to go to Bastion Fort.


Latest Release Crates.io
License Crates.io
Build Status (Linux / MacOS) Build Status
Build Status (Windows) appveyor build status
Downloads Crates.io
Discord

Bastion is a Fault-tolerant Runtime for Rust applications. It detect panics during runs of your code and serves a runtime to prevent abrupt exits. Also, it enables you to continue serving in case of a failure. You can select your own recovery scenario, scale your workers and define whole application on top of it.


Usage

Bastion comes with a default one-for-one strategy root supervisor. You can use this to launch automatically supervised tasks.

Why Bastion?

If one of the questions below answered with yes, then Bastion is just for you:

  • Do I need fault-tolerancy in my project?
  • Do I hate to implement weird Actor traits?
  • I shouldn't need a webserver to run an actor system, right?
  • Do I want to make my existing code unbreakable?
  • Do I have some trust issues against orchestration systems? Because I want to implement my own application lifecycle.

Features

  • Message-based communication makes this project a lean mesh of actor system.
    • without web servers, weird shenanigans, forced trait implementations, and static dispatch.
  • Runtime fault-tolerance makes it a good candidate for small scale distributed system code.
    • If you want to smell of Erlang and it's powerful aspects in Rust. That's it!
  • Supervision makes it easy to manage lifecycles.
    • Kill your application in certain condition or restart you subprocesses whenever a certain condition met. All up to you. And it should be up to you.

Get Started

Check basic root supervisor example in examples.

Examples cover possible use cases in the frame of the crate.

Include bastion to your project with:

bastion = "0.2"

In most simple way you can use Bastion like here:

use bastion::prelude::*;

fn main() {
    Bastion::platform();

    // Define, calculate or prepare messages to be sent to the processes. 
    let message = String::from("Some message to be passed");

    Bastion::spawn(
        |context: BastionContext, msg: Box<dyn Message>| {
            // Message can be selected with receiver here. Take action!
            receive! { msg,
                String => |e| { println!("Received string :: {}", e)},
                i32 => |e| {println!("Received i32 :: {}", e)},
                _ => println!("No message as expected. Default")
            }

            // Do some processing in body
            println!("root supervisor - spawn_at_root - 1");

            // Rebind to the system
            context.hook();
        },
        message,
    );

    Bastion::start()
}

Architecture of the Runtime

Runtime is structured by the user. Only root supervision comes in batteries-included fashion. Worker code, worker group redundancy, supervisors and their supervision strategies are defined by the user.

You can see architecture of the framework HERE.

Projects using Bastion

If you are using Bastion open a PR so we can include it in our showcase.

  • SkyNet (a Discord bot which is resending deleted messages)
    • Skynet is running since 0.1.3 release of Bastion on the cloud and haven't killed yet.

License

Licensed under either of

at your option.

Documentation

Official documentation is hosted on docs.rs.

Getting Help

Please head to our Discord or use StackOverflow

Discussion and Development

We use Discord for development discussions. Also please don't hesitate to open issues on GitHub ask for features, report bugs, comment on design and more! More interaction and more ideas are better!

Contributing to Bastion Open Source Helpers

All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.

A detailed overview on how to contribute can be found in the CONTRIBUTING guide on GitHub.

Thanks

Thanks to my dear mom (Günnur Bulut) who is an artist with many things to do but spending her efforts without any hesitation on small things that I requested (Like this logo). My shining star.

Also, thanks to my friend Berkan Yavri who helped to the idea of making this. Debated over the approaches that I took, spent time on thinking about this project with me.

bastion's People

Contributors

vertexclique avatar johntitor avatar xmclark avatar r3v2d0g avatar 0xflotus avatar mh84 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.