You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Luca Rea <lu...@contactlab.com> on 2014/12/02 12:00:36 UTC

RE: Req. Info - ts_lua

Hi,
if your fixes and improvements are coming up soon I'll wait for them before proceed testing some codes.

Thank you,
Luca

Re: Req. Info - ts_lua

Posted by Shu Kit Chan <ch...@gmail.com>.
Here is a small example of using ts_lua as a global plugin. please make
sure you a line of "tslua.so /home/kichan/main.lua" in plugin.config and
the content of main.lua is as below.

ts.add_package_cpath('/home/kichan/lib/?.so')
ts.add_package_path('/home/kichan/lualib/?.lua;/home/kichan/lualib/socket/?.lua')

local redis = require 'redis'
local client = redis.connect('127.0.0.1', 6379)

function do_global_send_response()
  local response = client:ping()
  local value = client:get('mykey')
  ts.client_response.header['X-Redis-Ping'] = tostring(response)
  ts.client_response.header['X-Redis-MyKey'] = value
end

Please note
1) I have a local redis and I set a "mykey" already beforehand
2) I downloaded and compiled luasocket and redis-lua and put all "so" into
/home/kichan/lib/ and all lua files from them into /home/kichan/lualib/

Thanks.

Kit


On Fri, Dec 5, 2014 at 12:47 PM, Luca Rea <lu...@contactlab.com> wrote:

> Hi,
> can you share with us some lines of code / examples?
>

RE: Req. Info - ts_lua

Posted by Luca Rea <lu...@contactlab.com>.
Hi,
can you share with us some lines of code / examples?

Re: Req. Info - ts_lua

Posted by Shu Kit Chan <ch...@gmail.com>.
Also we need to be careful in these use cases as well since the thread can
be blocked by the usage of the resource if we are not careful.
And perfomrnace will be affected.

Thanks.

Kit

On Fri, Dec 5, 2014 at 10:14 AM, Shu Kit Chan <ch...@gmail.com> wrote:

> I tried LuaSocket and redis-lua and I was able to define the
> client/resources globally and use it inside the hooks.
> But if you encounter any strange things, please feel free to answer us
> questions here.
>
> Also I have filed TS-3224 and TS-3225 for the fix and enhancement I am
> planning to commit soon.
>
> Thanks.
>
> Kit
>
> On Fri, Dec 5, 2014 at 4:02 AM, Luca Rea <lu...@contactlab.com> wrote:
>
>> Hi,
>> I mean tcp sockets for external resources such as messaging systems
>> (hornetq), db (redis) or others, the can be initiated, shared, controlled
>> and used directly by lua.
>>
>
>

Re: Req. Info - ts_lua

Posted by Shu Kit Chan <ch...@gmail.com>.
I tried LuaSocket and redis-lua and I was able to define the
client/resources globally and use it inside the hooks.
But if you encounter any strange things, please feel free to answer us
questions here.

Also I have filed TS-3224 and TS-3225 for the fix and enhancement I am
planning to commit soon.

Thanks.

Kit

On Fri, Dec 5, 2014 at 4:02 AM, Luca Rea <lu...@contactlab.com> wrote:

> Hi,
> I mean tcp sockets for external resources such as messaging systems
> (hornetq), db (redis) or others, the can be initiated, shared, controlled
> and used directly by lua.
>

RE: Req. Info - ts_lua

Posted by Luca Rea <lu...@contactlab.com>.
Hi,
I mean tcp sockets for external resources such as messaging systems (hornetq), db (redis) or others, the can be initiated, shared, controlled and used directly by lua.

RE: Req. Info - ts_lua

Posted by Luca Rea <lu...@contactlab.com>.
Hi,
Using lua does is possible to define and initiate some global shared resources (eg. tcp sockets) then call and control them in other hooks?