All Projects → poga → Actix Lua

poga / Actix Lua

Licence: mit
Safe Lua Scripting Environment for Actix

Programming Languages

rust
11053 projects
lua
6591 projects

Projects that are alternatives of or similar to Actix Lua

Minecase
Minecraft server based on Orleans
Stars: ✭ 581 (+448.11%)
Mutual labels:  actor-model
Pykka
🌀 Pykka makes it easier to build concurrent applications.
Stars: ✭ 944 (+790.57%)
Mutual labels:  actor-model
Orleans.activities
Workflow Foundation (.Net 4.x System.Activities workflows) over Microsoft Orleans framework, providing stable, long-running, extremely scalable processes with XAML designer support.
Stars: ✭ 61 (-42.45%)
Mutual labels:  actor-model
Actix
Actor framework for Rust.
Stars: ✭ 6,764 (+6281.13%)
Mutual labels:  actor-model
Mruby Actor
A actor library for distributed mruby
Stars: ✭ 11 (-89.62%)
Mutual labels:  actor-model
Orleans
Orleans is a cross-platform framework for building distributed applications with .NET
Stars: ✭ 8,131 (+7570.75%)
Mutual labels:  actor-model
Ponyc
🐴 Pony is an open-source, actor-model, capabilities-secure, high performance programming language
Stars: ✭ 4,857 (+4482.08%)
Mutual labels:  actor-model
So 5 5
SObjectizer: it's all about in-process message dispatching!
Stars: ✭ 87 (-17.92%)
Mutual labels:  actor-model
Akka Bootcamp
Self-paced training course to learn Akka.NET fundamentals from scratch
Stars: ✭ 880 (+730.19%)
Mutual labels:  actor-model
Idris Elixir
A code-generator for Idris that targets Elixir
Stars: ✭ 56 (-47.17%)
Mutual labels:  actor-model
Citybound
A work-in-progress, open-source, multi-player city simulation game.
Stars: ✭ 6,646 (+6169.81%)
Mutual labels:  actor-model
Nact
nact ⇒ node.js + actors ⇒ your services have never been so µ
Stars: ✭ 848 (+700%)
Mutual labels:  actor-model
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 (-54.72%)
Mutual labels:  actor-model
Riker
Easily build efficient, highly concurrent and resilient applications. An Actor Framework for Rust.
Stars: ✭ 745 (+602.83%)
Mutual labels:  actor-model
Ga server
基于protoactor框架的actor游戏服务器
Stars: ✭ 77 (-27.36%)
Mutual labels:  actor-model
Rockgo
A developing game server framework,based on Entity Component System(ECS).
Stars: ✭ 532 (+401.89%)
Mutual labels:  actor-model
Actor Zeta
Library that provides an actor style message-passing programming model (in C++).
Stars: ✭ 34 (-67.92%)
Mutual labels:  actor-model
Tractor
structured concurrent, Python parallelism
Stars: ✭ 88 (-16.98%)
Mutual labels:  actor-model
Actix Remote
Distributed actors for actix framework.
Stars: ✭ 80 (-24.53%)
Mutual labels:  actor-model
Ptii
Ptolemy II is an open-source software framework supporting experimentation with actor-oriented design.
Stars: ✭ 53 (-50%)
Mutual labels:  actor-model

actix-lua

Build Status Latest Version API Documentation

A safe scripting environment for actix with the Lua Programming Language:

  • Each LuaActor is an isolated Lua VM.
  • Communicate between actors with predefined message types: String, Integer, Number, Boolean, Nil, and Table.
  • Asynchronous send between actors with Lua coroutine.

For more info about the "safety", check rlua's README.

Synopsis

A basic Lua actor

extern crate actix_lua;
use actix_lua::{LuaActorBuilder, LuaMessage};

fn main () {
    let addr = LuaActorBuilder::new()
        .on_handle_with_lua(r#"return ctx.msg + 42"#)
        .build()
        .unwrap()
        .start();

    let res = addr.send(LuaMessage:from(100));
    // return: 142
}

You can send messages to other actor asynchronously with ctx.send

struct Callback;
impl Actor for Callback {
    type Context = Context<Self>;
}

impl Handler<LuaMessage> for Callback {
    type Result = LuaMessage;

    fn handle(&mut self, msg: LuaMessage, _ctx: &mut Context<Self>) -> Self::Result {
        LuaMessage::String("hello".to_string())
    }
}

let mut actor = LuaActorBuilder::new()
    // create a new LuaActor from a lua script when the actor is started.
    // send message to the newly created actor with `ctx.send`, block and wait for its response.
    .on_started_with_lua(
        r#"
    local result = ctx.send("callback, "Hello")
    print(result) -- print "hello"
    "#).build()
    .unwrap();

actor.add_recipients("callback", Callback.start().recipient());

actor.start();

Install

Add actix-lua to your Cargo.toml:

[dependencies]
actix-lua = "0.7"

Example

Check examples directory.

There's also a write-up about analyzing streaming data with actix-lua. link

Lua Actor

Use LuaActor to integrate Lua scripts to your system with actor model.

Message

In actor model, actors communicate with messages. LuaMessage is the only message type accepted by LuaActor:

  • LuaMessage can be converted to/from primitive types with LuaMessage::from().
  • Lua types(e.g. number, table) will be convert to LuaMessage automatically.

Lua API

Note: Avoid declaring global variables in your Lua script. It might conflict with future actix-lua update and break your program.

ctx.msg

The message sent to Lua actor.

ctx.notify(msg)

Send message msg to self.

ctx.notify_later(msg, seconds)

Send message msg to self after specified period of time.

local result = ctx.send(recipient, msg)

Send message msg to `recipient asynchronously and wait for response.

Equivalent to actix::Recipient.send.

ctx.do_send(recipient, msg)

Send message msg to recipient.

Equivalent to actix::Recipient.do_send.

ctx.terminate()

Terminate actor execution.

License

The MIT License

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].