Skip to content

Perhaps provide some more gradual examples on the https://bastion.rs/ site? #334

@werner291

Description

@werner291

Hello!

I've looked at https://bastion.rs/, and I must say that, as a newcomer, I find the examples a bit intimidating.

I have a basic understanding of how actors work, but when I look at the site, as a newcomer, what I see:

use bastion::prelude::*;

#[fort::root]
async fn main(_: BastionContext) -> Result<(), ()> {
    println!("Running in Bastion runtime!");
    Ok(())
}

My reaction: "Ok... I can print things inside of a 'runtime', whatever that is... Looks simple enough."

And then:

use bastion::prelude::*;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

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

    let started = AtomicBool::new(false);
    let started = Arc::new(started);

    Bastion::children(|children| {
        children.with_exec(move |ctx: BastionContext| {
            let started = started.clone();
            async move {
                println!("Started!");

                if started.swap(true, Ordering::SeqCst) {
                    println!("Already started once. Stopping...");

                    // This will ask the system to stop itself...
                    Bastion::stop();
                    // ...and this will stop this child immediately...
                    return Ok(());
                    // Note that if Err(()) was returned, the child would have been
                    // restarted (and if the system wasn't stopping).
                }

                // This will return None.
                let try_recv = ctx.try_recv().await;
// Lots more lines with supervisors, children, child groups, etc...

Bastion certainly looks interesting, and I'd love to learn more about it, but... Wow, that's a lot going on. What's the difference between a supervisor? A child group? A child? How does Fort come into that? What's a context? A runtime? Help!

As a basic example, it's a bit intimidating, there's kinda way too many concepts being introduced at once. It's probably going to scare away some beginners.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions