actix-lua
A safe scripting environment for actix with the Lua Programming Language.
Synopsis
extern crate actix_lua;
use ;
Install
Add actix-lua
to your Cargo.toml
:
[]
= "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
:
LuaMessage
can be converted to/from primitive types withLuaMessage::from()
.- Lua types(e.g. number, table) will be convert to
LuaMessage
automatically.
Lua API
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