actix-lua

Build Status Latest Version API Documentation

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

Synopsis

```rust extern crate actixlua; use actixlua::{LuaActorBuilder, LuaMessage};

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

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

} ```

Install

Add actix-lua to your Cargo.toml:

toml [dependencies] actix-lua = "0.3"

Example

Check examples directory.

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:

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 recipient = ctx.new_actor(script_path, [actor_name])

Create a new actor with given lua script. returns a recipient which can be used in ctx.send and ctx.do_send.

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