1) No. you don't need to do anything in txn close hook.

2) See the example in the documentation. I think we can definitely
improve the text a bit. What it means is that you need to add a hook
inside do_remap and ts.schedule() can only be called inside that hook
function.
It is similar to
https://docs.trafficserver.apache.org/en/latest/developer-guide/api/functions/TSContSchedule.en.html
However, inside ts_lua we only support net and task.

3) There is an example (the second one) close to the beginning of the
doc - 
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

4) we don't have this for now. Suggestions/patches are welcome.

IMHO, you don't need to use ts.schedule() . You can directly use
luasocket inside __init__ function since this is run inside
TSPluginInit(). You can use global variable to store the results you
want similar to the __init__ example in the document .
However, pls be aware that we instantiate multiple lua state and thus
we run __init__ for each of those state so it may result in a slow
startup time for you. See jira -
https://issues.apache.org/jira/browse/TS-4994 for a patch for this.

Thanks. Let me know if i can provide any more help.

Kit



On Thu, Dec 8, 2016 at 3:52 PM, Di Li <di...@apple.com> wrote:
> Hey Guys,
>
> Several questions about the ts-lua , just start to use it, so some question
> may seem very simple
>
> 1. question about  log part “[globalHookHandler] has txn hook -> adding txn
> close hook handler to release resources”
>
> for example I’m using the following code, and the debug log shows above log
> , do I need to do anything to handle a txt close hook to release the
> resource, or I should just ignore the log
>
>
> function do_some_work()
>   - - do some logic
>   return 0
> end
>
>
> function do_global_read_request()
>    ts.debug('this is do_global_read_request')
>    ts.hook(TS_LUA_HOOK_READ_REQUEST_HDR, do_some_work)
>    return 0
> end
>
>
> 2. question for ts.schedule
>
> what does “after do_remap” means, is that after hook TS_HTTP_POST_REMAP_HOOK
> ?
> what are the types in “ THREAD_TYPE” other than the one in the example
> "TS_LUA_THREAD_POOL_NET”, and what’s the different between those types.
>
>
> ts.schedule
> syntax: ts.schedule(THREAD_TYPE, sec, FUNCTION, param1?, param2?, ...)
> context: after do_remap
>
>
> 3. init function being called when traffic_server starts
>
> is there a init function being called when traffic_server starts, like the
> following in nginx
>
> https://github.com/openresty/lua-nginx-module#init_worker_by_lua
>
>
> 4. Global shared lua dict
>
> is there a global shared lua dict, that will not has the lift time as
> ts.ctx, something like lua_shared_dict in nginx ?
>
>
> What I’m trying to do here is that when traffic server starts up, it will
> try to call a init script, which will init a scheduler to fetch a url either
> internal or external and get that response store to a shared_lua_dict as
> key/value pairs, and later on each of the request comes to the ATS will try
> to check the key/values use that shared_lua_dict. With that in mind, I need
> to understand those 4 questions above.
>
>
>
> Thanks,
> Di Li
>
>

Reply via email to