All Projects â†’ Restioson â†’ xtra

Restioson / xtra

Licence: other
🎭 A tiny actor framework

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to xtra

Coerce Rs
Coerce - an asynchronous (async/await) Actor runtime and cluster framework for Rust
Stars: ✭ 231 (+108.11%)
Mutual labels:  asynchronous, actor-model, async-await
Asyncorm
Fully Async ORM inspired in django's
Stars: ✭ 182 (+63.96%)
Mutual labels:  asynchronous, async-await
Async Backplane
Simple, Erlang-inspired fault-tolerance framework for Rust Futures.
Stars: ✭ 113 (+1.8%)
Mutual labels:  asynchronous, async-await
Aiomisc
aiomisc - miscellaneous utils for asyncio
Stars: ✭ 200 (+80.18%)
Mutual labels:  asynchronous, async-await
Egghead Async Await
Code for my "Asynchronous JavaScript with async/await" egghead.io course:
Stars: ✭ 74 (-33.33%)
Mutual labels:  asynchronous, async-await
Radon
Object oriented state management solution for front-end development.
Stars: ✭ 80 (-27.93%)
Mutual labels:  asynchronous, async-await
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (+19.82%)
Mutual labels:  asynchronous, async-await
ComposableAsync
Create, compose and inject asynchronous behaviors in .Net Framework and .Net Core.
Stars: ✭ 28 (-74.77%)
Mutual labels:  asynchronous, actor-model
async
Asynchronous programming for R -- async/await and generators/yield
Stars: ✭ 37 (-66.67%)
Mutual labels:  asynchronous, async-await
EnumerableAsyncProcessor
Process Multiple Asynchronous Tasks in Various Ways - One at a time / Batched / Rate limited / Concurrently
Stars: ✭ 84 (-24.32%)
Mutual labels:  asynchronous, async-await
Ea Async
EA Async implements async-await methods in the JVM.
Stars: ✭ 1,085 (+877.48%)
Mutual labels:  asynchronous, async-await
Rx.Book
High level asynchronous programming with Reactive Extensions
Stars: ✭ 67 (-39.64%)
Mutual labels:  asynchronous, async-await
Async Reduce
Reducer for similar simultaneously coroutines
Stars: ✭ 17 (-84.68%)
Mutual labels:  asynchronous, async-await
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (+0.9%)
Mutual labels:  asynchronous, async-await
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+521.62%)
Mutual labels:  asynchronous, async-await
Thunks
A small and magical composer for all JavaScript asynchronous.
Stars: ✭ 523 (+371.17%)
Mutual labels:  asynchronous, async-await
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (+189.19%)
Mutual labels:  asynchronous, actor-model
Async Io Demo
demo for rust asynchronous io: from mio to stackless coroutine
Stars: ✭ 334 (+200.9%)
Mutual labels:  asynchronous, async-await
aioudp
Asyncio UDP server
Stars: ✭ 21 (-81.08%)
Mutual labels:  asynchronous, async-await
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (-72.07%)
Mutual labels:  asynchronous, async-await

xtra

A tiny, fast, and safe actor framework. It is modelled around Actix (copyright and license here).

For better ergonomics with xtra, try the spaad crate.

Features

  • Safe: there is no unsafe code in xtra.
  • Tiny: xtra is less than 1k loc.
  • Lightweight: xtra has few dependencies, most of which are lightweight (except futures).
  • Asynchronous and synchronous message handlers.
  • Simple asynchronous message handling interface which allows async/await syntax even when borrowing self.
  • Does not depend on its own runtime and can be run with any futures executor (Tokio, async-std, smol, and wasm-bindgen-futures have the Actor::spawn convenience method implemented out of the box).
  • Quite fast. Running on Tokio, <170ns time from sending a message to it being processed for sending without waiting for a result on my development machine with an AMD Ryzen 3 3200G.
  • However, it is also relatively new and less mature than other options.

Example

use xtra::prelude::*;
use xtra::spawn::Tokio;
use async_trait::async_trait;

struct Printer {
    times: usize,
}

impl Printer {
    fn new() -> Self {
        Printer { times: 0 }
    }
}

impl Actor for Printer {}

struct Print(String);
impl Message for Print {
    type Result = ();
}

#[async_trait]
impl Handler<Print> for Printer {
    async fn handle(&mut self, print: Print, _ctx: &mut Context<Self>) {
        self.times += 1; // no ActorFuture or anything just to access `self`
        println!("Printing {}. Printed {} times so far.", print.0, self.times);
    }
}

#[tokio::main]
async fn main() {
    let addr = Printer::new().create(None).spawn(&mut Tokio::Global);
    loop {
        addr.send(Print("hello".to_string()))
            .await
            .expect("Printer should not be dropped");
    }
}

For a longer example, check out Vertex, a chat application written with xtra and spaad on the server.

Too verbose? Check out the spaad sister-crate!

Okay, sounds great! How do I use it?

Check out the docs and the examples to get started! Enabling the with-tokio-1, with-async_std-1, with-smol-1, or with-wasm_bindgen-0_2 features is recommended in order to enable some convenience methods (such as Actor::spawn). Which you enable will depend on which executor you want to use (check out their docs to learn more about each). If you have any questions, feel free to open an issue or message me on the Rust discord.

Cargo features

  • timing: enables the notify_interval method, and brings in the futures-timer crate.
  • with-async_std-1: enables integration with async-std.
  • with-smol-1: enables integration with smol. Note that this requires smol 1.1 as 1.1 had a minor breaking change from 1.0 which leads to xtra no longer compiling on 1.0 and 1.1 simultaneously.
  • with-tokio-1: enables integration with tokio.
  • with-wasm_bindgen-0_2: enables integration with wasm-bindgen, and particularly its futures crate.
  • with-tracing-0_1: enables the Instrumented wrapper and InstrumentedExt traits, to integrate with tracing. This allows a tracing span to follow through execution of a message, either as a child of the sending span, or as a separate span marked as follows_from the sending span.

Latest Breaking Changes

To see the breaking changes for each version, see here. The latest version is 0.6.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].