Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project documentation #28

Merged
merged 11 commits into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on: push
name: Clippy Check
jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [Unreleased](https://github.com/vertexclique/bastion/compare/v0.1.4-alpha.1...HEAD)

### Merged

- Context spawn level tests [`#27`](https://github.com/vertexclique/bastion/pull/27)
- Change license to use Apache-2.0/MIT [`#26`](https://github.com/vertexclique/bastion/pull/26)
- Multi OS builds [`#25`](https://github.com/vertexclique/bastion/pull/25)
- Spawn from the context [`#19`](https://github.com/vertexclique/bastion/pull/19)
- File extension it seems [`#24`](https://github.com/vertexclique/bastion/pull/24)
- Move appveyor file, since it is not picked up. [`#23`](https://github.com/vertexclique/bastion/pull/23)
- Build on windows [`#21`](https://github.com/vertexclique/bastion/pull/21)
- Remove nightly features [`#20`](https://github.com/vertexclique/bastion/pull/20)
- did you mean 'abrupt'? [`#10`](https://github.com/vertexclique/bastion/pull/10)
- Shutdown implementation [`#14`](https://github.com/vertexclique/bastion/pull/14)

### Commits

- All documentation is complete [`d3084ba`](https://github.com/vertexclique/bastion/commit/d3084ba1c05e6a911b30a57f61acd823d83aa872)
- Refactor supervisors to carry out context to share data between children [`324a80b`](https://github.com/vertexclique/bastion/commit/324a80b1623b18b9a874ec78759af28cbb8eb61f)
- Context documentation [`58f5943`](https://github.com/vertexclique/bastion/commit/58f5943bbf6176beeba6da6b71fc5d875a31cd0e)

## [v0.1.4-alpha.1](https://github.com/vertexclique/bastion/compare/v0.1.3...v0.1.4-alpha.1) - 2019-07-27

### Merged

- Make prelude separation [`#12`](https://github.com/vertexclique/bastion/pull/12)
- Introduce receive utilities for message [`#11`](https://github.com/vertexclique/bastion/pull/11)
- did you mean 'abrupt'? [`#1`](https://github.com/vertexclique/bastion/pull/1)

### Fixed

- Introduce receive utilities for message [`#1`](https://github.com/vertexclique/bastion/issues/1)

### Commits

- Fix communication example [`806bc22`](https://github.com/vertexclique/bastion/commit/806bc2229b6b089b1c5f6e0f1e387dff9492e041)
- Update code example in the readme [`684a7bb`](https://github.com/vertexclique/bastion/commit/684a7bb7101289fb74fe824d3f5e3c5938156f64)
- (cargo-release) version 0.1.4-alpha.1 [`9eaf5d2`](https://github.com/vertexclique/bastion/commit/9eaf5d298f28caa28763291469a2e9ccdd716611)

## [v0.1.3](https://github.com/vertexclique/bastion/compare/v0.1.2...v0.1.3) - 2019-07-21

### Commits

- (cargo-release) version 0.1.3 [`bbdd5bc`](https://github.com/vertexclique/bastion/commit/bbdd5bc1be225cc14c6d9a64585fcdcccc29de84)
- Reword logging entry format [`0fb11d1`](https://github.com/vertexclique/bastion/commit/0fb11d19db943e8eebfa9ca4e136db161b1275aa)
- (cargo-release) start next development iteration 0.1.2 [`da63455`](https://github.com/vertexclique/bastion/commit/da63455761ae2d5bd6ff3a34c74b87fc49441d71)

## [v0.1.2](https://github.com/vertexclique/bastion/compare/v0.1.0...v0.1.2) - 2019-07-21

### Commits

- Cooperatively assembled message [`136cdb6`](https://github.com/vertexclique/bastion/commit/136cdb6056ede3c1c612ba0ede7479abb4da52fc)
- Export root spawn [`871261b`](https://github.com/vertexclique/bastion/commit/871261bf72780f34013266b38edac6bb80416c3f)
- README update [`09b3e68`](https://github.com/vertexclique/bastion/commit/09b3e689f9b38db5963d14bbbfea65df9bba6e3a)

## v0.1.0 - 2019-07-21

### Commits

- Initial commit [`be42fad`](https://github.com/vertexclique/bastion/commit/be42fad8120e8e92f6a98133d054681950123cbf)
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description = "Fault-tolerant Runtime for Rust applications"
authors = ["Mahmut Bulut <vertexclique@gmail.com>"]
keywords = ["fault-tolerant", "runtime", "actor", "system"]
categories = []
homepage = "https://github.com/vertexclique/bastion"
repository = "https://github.com/vertexclique/bastion"
homepage = "https://github.com/bastion-rs/bastion"
repository = "https://github.com/bastion-rs/bastion"
documentation = "https://docs.rs/bastion"
readme = "README.md"
license = "Apache-2.0/MIT"
Expand All @@ -28,7 +28,7 @@ exclude = [
]

[badges]
travis-ci = { repository = "vertexclique/bastion", branch = "master" }
travis-ci = { repository = "bastion-rs/bastion", branch = "master" }
maintenance = { status = "actively-developed" }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
52 changes: 39 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="https://github.com/vertexclique/bastion/blob/master/img/bastion.png"><br>
<img src="https://github.com/bastion-rs/bastion/blob/master/img/bastion.png"><br>
</div>

-----------------
Expand Down Expand Up @@ -29,23 +29,23 @@
<tr>
<td>License</td>
<td>
<a href="https://github.com/vertexclique/bastion/blob/master/LICENSE">
<a href="https://github.com/bastion-rs/bastion/blob/master/LICENSE">
<img alt="Crates.io" src="https://img.shields.io/crates/l/bastion.svg?style=popout-square">
</a>
</td>
</tr>
<tr>
<td>Build Status (Linux / MacOS)</td>
<td>
<a href="https://travis-ci.org/vertexclique/bastion">
<img src="https://travis-ci.org/vertexclique/bastion.svg?branch=master" alt="travis build status" />
<a href="https://travis-ci.org/bastion-rs/bastion">
<img src="https://travis-ci.org/bastion-rs/bastion.svg?branch=master" alt="travis build status" />
</a>
</td>
</tr>
<tr>
<td>Build Status (Windows)</td>
<td>
<a href="https://ci.appveyor.com/project/vertexclique/bastion/branch/master">
<a href="https://ci.appveyor.com/project/bastion-rs/bastion/branch/master">
<img src="https://ci.appveyor.com/api/projects/status/ksfqpeuq9gxspnb6/branch/master?svg=true" alt="appveyor build status" />
</a>
</td>
Expand Down Expand Up @@ -91,9 +91,27 @@ define whole application on top of it.
Bastion comes with a default one-for-one strategy root supervisor.
You can use this to launch automatically supervised tasks.

Check [root supervisor](https://github.com/vertexclique/bastion/blob/master/examples/root_spv.rs) example in examples.
## 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.

[Examples](https://github.com/vertexclique/bastion/blob/master/examples) cover all the use cases in the frame of the crate.
## 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](https://github.com/bastion-rs/bastion/blob/master/examples/root_spv.rs) example in examples.

[Examples](https://github.com/bastion-rs/bastion/blob/master/examples) cover possible use cases in the frame of the crate.

Include bastion to your project with:
```toml
Expand All @@ -111,7 +129,7 @@ fn main() {
let message = String::from("Some message to be passed");

Bastion::spawn(
|context, msg: Box<dyn Message>| {
|context: BastionContext, msg: Box<dyn Message>| {
// Message can be selected with receiver here. Take action!
receive! { msg,
String => |e| { println!("Received string :: {}", e)},
Expand All @@ -132,18 +150,26 @@ fn main() {
}
```

## Structure of the Runtime
## 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 overall architecture of the framework here:
![](img/bastion-arch.png)
You can see architecture of the framework [HERE](https://github.com/bastion-rs/bastion/blob/master/img/bastion-arch.png).

## Projects using Bastion
If you are using Bastion open a PR so we can include it in our showcase.
* [SkyNet](https://github.com/vertexclique/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

License is [MIT](https://github.com/vertexclique/bastion/blob/master/LICENSE)
Licensed under either of

* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

## Documentation

Expand All @@ -156,7 +182,7 @@ Please head to our [Gitter](https://gitter.im/bastionframework/community) or use
We use [Gitter](https://gitter.im/bastionframework/community) 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](https://www.codetriage.com/vertexclique/bastion/badges/users.svg)](https://www.codetriage.com/vertexclique/bastion)
## Contributing to Bastion [![Open Source Helpers](https://www.codetriage.com/bastion-rs/bastion/badges/users.svg)](https://www.codetriage.com/bastion-rs/bastion)

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

Expand Down
18 changes: 9 additions & 9 deletions benches/bench_one_for_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ extern crate test;
mod tests {
use super::*;
use bastion::bastion::Bastion;
use bastion::bastion::PLATFORM;

use bastion::config::BastionConfig;
use bastion::context::BastionContext;
use bastion::supervisor::SupervisionStrategy;


use log::LevelFilter;
use std::borrow::{Borrow, BorrowMut};

use std::sync::Once;
use std::{fs, thread, time};
use std::{thread, time};
use test::Bencher;
use tokio::prelude::*;
use tokio::runtime::{Builder, Runtime};



static INIT: Once = Once::new();

Expand All @@ -26,7 +26,7 @@ mod tests {
log_level: LevelFilter::Debug,
in_test: true,
};
let bastion = Bastion::platform_from_config(config);
let _bastion = Bastion::platform_from_config(config);
});
}

Expand All @@ -43,7 +43,7 @@ mod tests {
let message = "Supervision Message".to_string();

Bastion::spawn(
|p, msg| {
|_p, _msg| {
panic!("root supervisor - spawn_at_root - 1");
},
message,
Expand Down
6 changes: 3 additions & 3 deletions examples/root_spv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ fn main() {
Bastion::spawn(
|context: BastionContext, msg: Box<dyn Message>| {
// Message can be used here.
match Receive::<String>::from(msg) {
Receive(Some(o)) => println!("Received {}", o),
_ => println!("other message type..."),
receive! { msg,
String => |o| { println!("Received {}", o) },
_ => println!("other message type...")
}

println!("root supervisor - spawn_at_root - 1");
Expand Down
2 changes: 1 addition & 1 deletion examples/spawn_from_context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bastion::prelude::*;
use log::LevelFilter;
use std::{fs, thread, time};


fn main() {
let config = BastionConfig {
Expand Down
2 changes: 1 addition & 1 deletion examples/spv_children_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {

let tx = p.bcast_tx.as_ref().unwrap().clone();

tx.send(Box::new(new_msg));
let _ = tx.send(Box::new(new_msg));

let rx = p.bcast_rx.clone().unwrap();
if let Ok(message) = rx.try_recv() {
Expand Down
Binary file added img/bastion-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading