All Projects → intendednull → wactor

intendednull / wactor

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Ultra minimal actor API wrapper for lunatic

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to wactor

Ray
项目停止更新,新项目:https://github.com/RayTale/Vertex
Stars: ✭ 635 (+2440%)
Mutual labels:  actor
Qpn
QP-nano real-time embedded framework/RTOS for embedded systems based on active objects (actors) and hierarchical state machines
Stars: ✭ 107 (+328%)
Mutual labels:  actor
Sobjectizer
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
Stars: ✭ 172 (+588%)
Mutual labels:  actor
Actix
Actor framework for Rust.
Stars: ✭ 6,764 (+26956%)
Mutual labels:  actor
Actor4j Core
Actor4j is an actor-oriented Java framework. Useful for building lightweighted microservices (these are the actors themselves or groups of them). Enhanced performance of message passing.
Stars: ✭ 48 (+92%)
Mutual labels:  actor
Vertex
Vertex is a distributed, ultimately consistent, event traceable cross platform framework based on Orleans, which is used to build high-performance, high throughput, low latency, scalable distributed applications
Stars: ✭ 117 (+368%)
Mutual labels:  actor
Coobjc
coobjc provides coroutine support for Objective-C and Swift. We added await method、generator and actor model like C#、Javascript and Kotlin. For convenience, we added coroutine categories for some Foundation and UIKit API in cokit framework like NSFileManager, JSON, NSData, UIImage etc. We also add tuple support in coobjc.
Stars: ✭ 3,921 (+15584%)
Mutual labels:  actor
elfo
Your next actor system
Stars: ✭ 38 (+52%)
Mutual labels:  actor
Earl
Service Objects for Crystal (Agents, Artists, Supervisors, Pools, ...)
Stars: ✭ 89 (+256%)
Mutual labels:  actor
Fibry
The first Java Actor System supporting fibers from Project Loom
Stars: ✭ 146 (+484%)
Mutual labels:  actor
Actor
A type-safe Actor class and WiredActor for sending functions as messages
Stars: ✭ 16 (-36%)
Mutual labels:  actor
Actor.js
Elixir-style actors in JavaScript
Stars: ✭ 48 (+92%)
Mutual labels:  actor
Qpcpp
QP/C++ real-time embedded framework/RTOS for embedded systems based on active objects (actors) and hierarchical state machines
Stars: ✭ 124 (+396%)
Mutual labels:  actor
Qbit
The Java microservice lib. QBit is a reactive programming lib for building microservices - JSON, HTTP, WebSocket, and REST. QBit uses reactive programming to build elastic REST, and WebSockets based cloud friendly, web services. SOA evolved for mobile and cloud. ServiceDiscovery, Health, reactive StatService, events, Java idiomatic reactive programming for Microservices.
Stars: ✭ 702 (+2708%)
Mutual labels:  actor
Bastion
Highly-available Distributed Fault-tolerant Runtime
Stars: ✭ 2,333 (+9232%)
Mutual labels:  actor
Akka.net
Port of Akka actors for .NET
Stars: ✭ 4,024 (+15996%)
Mutual labels:  actor
Cpp Rotor
Event loop friendly C++ actor micro-framework
Stars: ✭ 111 (+344%)
Mutual labels:  actor
kamon-akka
Kamon Instrumentation for Akka
Stars: ✭ 44 (+76%)
Mutual labels:  actor
young-crawler
scala结合actor编写的分布式网络爬虫
Stars: ✭ 15 (-40%)
Mutual labels:  actor
Xactor
Xactor is a rust actors framework based on async-std
Stars: ✭ 146 (+484%)
Mutual labels:  actor

Wactor

A dead simple actor api wrapper for lunatic.

Actors run on isolated green threads. They cannot share memory, and communicate only through input and output messages. Consequently messages must be serialized to travel between threads.

Example

use serde::{Deserialize, Serialize};
use wactor::*;

struct Counter {
    count: u32,
}

#[derive(Serialize, Deserialize)]
enum Input {
    AddOne,
}

#[derive(Serialize, Deserialize, PartialEq, Debug)]
enum Output {
    Count(u32),
}

impl Actor for Counter {
    type Input = Input;
    type Output = Output;

    fn create() -> Self {
        Self { count: 0 }
    }

    fn handle(&mut self, msg: Self::Input, link: &Link<Self>) {
        match msg {
            Input::AddOne => {
                // Increment count by 1.
                self.count += 1;
                // Respond with new count. This fails if our recipient has been dropped.
                link.respond(Output::Count(self.count)).ok();
            }
        }
    }
}

fn main() {
    // Spawn our actor. We get a bridge for sending and receiving messages. Can be cloned for
    // multiple owners. Actor is dropped after all bridges have been dropped.
    let bridge = wactor::spawn::<Counter>();
    // Send our input message. This fails if our actor has panicked (unrecoverable error).
    bridge.send(Input::AddOne).expect("Dead actor");
    // Block until a response is received. This also fails if our actor has panicked.
    let result = bridge.receive();
    // Assert we received the correct value.
    assert_eq!(result, Ok(Output::Count(1)));
}

How to run

Install lunatic then build and run:

cargo build --release --target=wasm32-wasi --example basic
lunatic target/wasm32-wasi/release/examples/basic.wasm
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].