safe Lua scripting environment for Actix
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Aug 25, 2018
examples rename http-server example to actix-web Dec 12, 2018
src remove `ctx.new_actor` Dec 9, 2018
.gitignore add lua-web example Aug 25, 2018
.travis.yml remove dependency on rust-embed, bump to 0.3 Aug 8, 2018
Cargo.toml upgrade to rust 2018 Dec 6, 2018
LICENSE add README and LICENSE Jul 25, 2018 remove `ctx.new_actor` Dec 9, 2018


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.


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"#)

    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 {

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.
    local result = ctx.send("callback, "Hello")
    print(result) -- print "hello"

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



Add actix-lua to your Cargo.toml:

actix-lua = "0.5"


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.


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.


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


The message sent to Lua actor.


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.


Terminate actor execution.


The MIT License