I'm Luvin It

Introduction to Luvit and Virgo project

Tomaz Muraus
[email protected]
FOSDEM 2013, Brussels, Belgium

Agenda

Who am I?

What is Luvit?

Luvit - HTTP Server Example

          local http = require('http')

          http.createServer(function (req, res)
            local body = 'Hello FOSDEM\n'
            res:writeHead(200, {
              ['Content-Type'] = 'text/plain',
              ['Content-Length'] = #body
            })
            res:finish(body)
          end):listen(8080)

          print('Server listening at http://localhost:8080/')
        

Luvit History

Why Should I Care?

Lua C stack based API

          #include 
          #include 
          #include 
          #include 

          int main()
          {
              lua_State *L = luaL_newstate();
              if (luaL_dostring(L, "function foo (x,y) return x+y end")) exit(1);
              lua_getglobal(L, "foo");
              lua_pushinteger(L, 5);
              lua_pushinteger(L, 3);
              lua_call(L, 2, 1);
              printf("Result: %d\n", lua_tointeger(L, -1));
              lua_close(L);
              return 0;
          }
        

Virgo

Why We Picked Luvit?

Virgo - layers



Virgo - Goals

Virgo - Memory Usage

Virgo - communication with the endpoint(s)



Virgo - protocol example (request)

        {
          "v": "1",
          "id": 0,
          "source": "agentA",
          "target": "endpoint",
          "method": "heartbeat.post",
          "params": {
            "timestamp": 1325645515246
          }
        }
        

Virgo - protocol example (response)

        {
          "v": "1",
          "id": 1,
          "source": "endpoint",
          "target": "agentA",
          "result": {
            "timestamp": 1325645515246
          }
        }
        

Thanks