---
layout: post
title: "GsoC 2014: Lua Scripting support for Monkey, Week 12"
date: 2014-08-11 01:12:58 +0530
comments: true
categories:
---

In order to implement a nonblocking way to excecute the lua code for
the plugin I have been reading ngnix's
[http://wiki.nginx.org/HttpLuaModule](HttpLuaModule). The module is
implemented with one LUA VM per worker and each lua call/request is
run with it's own coroutine. This seems to be a better approach than
the one I am currently using as this removes the latency involved in
creating a Lua state per request as coroutines are much more
lightweight compared to lua_state, I am currently rewriting some of
the code to work in this way as it might offer much more flexibility
and performance.

The non blocking behaviour of the module is achieved by using
coroutines with blocking calls that yields to the event loop. This is
done using something called `cosockets` which makes writing sequential
code that works in non blocking way. In order to implement similar
functionality in monkey, this cosockets api has to rewritten to
integrate with monkeys event loop. Although this would require in
effect writing a socket library for lua that specifically works with
monkey, this will make adding more libraries easier in the future as
well as make it possible to use many of the existing libraries for
openresty to monkey lua without much effort other than that required
for dealing with lua 5.1 vs lua 5.2 issues.

This week I completed a for the api documentation. I have a version of
the plugin that is functional in the testing branch of the repo.
Making the plugin non blocking by using co sockets requires some
effort and I have started writing code for this. I will try to finish
this before the pencils down date.

code: https://github.com/diadara/monkey_lua
blog:
http://diadara.github.io/blog/2014/08/11/gsoc-2014-lua-scripting-support-for-monkey/

-- 
Nithin Saji
Bits Pilani
_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to