You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ki...@apache.org on 2016/10/14 01:59:08 UTC

[trafficserver] branch master updated (837d838 -> b329684)

This is an automated email from the ASF dual-hosted git repository.

kichan pushed a change to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git.

      from  837d838   TS-4966: Fix process manager thread to support TS API.
       new  28df446   TS-4592: Add support for process ID and txn ID in ts_lua
       new  b329684   change to ts.process.uuid() and add error handling for it

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/admin-guide/plugins/ts_lua.en.rst     | 36 +++++++++++++++++++++++++++++++
 plugins/experimental/ts_lua/ts_lua_http.c | 17 +++++++++++++++
 plugins/experimental/ts_lua/ts_lua_misc.c | 23 ++++++++++++++++++++
 3 files changed, 76 insertions(+)

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].

[trafficserver] 02/02: change to ts.process.uuid() and add error handling for it

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kichan pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit b3296842207bcf5661bd6027ce0218f158636a35
Author: Kit Chan <ki...@apache.org>
AuthorDate: Wed Oct 12 23:18:36 2016 -0700

    change to ts.process.uuid() and add error handling for it
---
 doc/admin-guide/plugins/ts_lua.en.rst     |  8 ++++----
 plugins/experimental/ts_lua/ts_lua_misc.c | 10 +++++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/doc/admin-guide/plugins/ts_lua.en.rst b/doc/admin-guide/plugins/ts_lua.en.rst
index 9794ffc..a5dc6e5 100644
--- a/doc/admin-guide/plugins/ts_lua.en.rst
+++ b/doc/admin-guide/plugins/ts_lua.en.rst
@@ -131,9 +131,9 @@ is always available within lua script. This package can be introduced into Lua l
 
 `TOP <#ts-lua-plugin>`_
 
-ts.process_id
--------------
-**syntax:** *val = ts.process_id()*
+ts.process.uuid
+---------------
+**syntax:** *val = ts.process.uuid()*
 
 **context:** global
 
@@ -143,7 +143,7 @@ Here is an example:
 
 ::
 
-    local pid = ts.process_id()  -- a436bae6-082c-4805-86af-78a5916c4a91
+    local pid = ts.process.uuid()  -- a436bae6-082c-4805-86af-78a5916c4a91
 
 `TOP <#ts-lua-plugin>`_
 
diff --git a/plugins/experimental/ts_lua/ts_lua_misc.c b/plugins/experimental/ts_lua/ts_lua_misc.c
index e82e1ca..51e6ac5 100644
--- a/plugins/experimental/ts_lua/ts_lua_misc.c
+++ b/plugins/experimental/ts_lua/ts_lua_misc.c
@@ -34,9 +34,13 @@ static void ts_lua_inject_misc_variables(lua_State *L);
 void
 ts_lua_inject_misc_api(lua_State *L)
 {
-  /* ts.process_id() */
+  lua_newtable(L);
+
+  /* ts.process.uuid() */
   lua_pushcfunction(L, ts_lua_get_process_id);
-  lua_setfield(L, -2, "process_id");
+  lua_setfield(L, -2, "uuid");
+
+  lua_setfield(L, -2, "process");
 
   /* ts.now() */
   lua_pushcfunction(L, ts_lua_get_now_time);
@@ -78,7 +82,7 @@ ts_lua_get_process_id(lua_State *L)
   if (process) {
     s = TSUuidStringGet(process);
   } else {
-    s = "";
+    return luaL_error(L, "not able to get process uuid");
   }
   lua_pushstring(L, s);
   return 1;

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.

[trafficserver] 01/02: TS-4592: Add support for process ID and txn ID in ts_lua

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kichan pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 28df44603225476c9e8223e2d25d0698fc7aef88
Author: Kit Chan <ki...@apache.org>
AuthorDate: Tue Oct 11 08:41:08 2016 -0700

    TS-4592: Add support for process ID and txn ID in ts_lua
---
 doc/admin-guide/plugins/ts_lua.en.rst     | 36 +++++++++++++++++++++++++++++++
 plugins/experimental/ts_lua/ts_lua_http.c | 17 +++++++++++++++
 plugins/experimental/ts_lua/ts_lua_misc.c | 19 ++++++++++++++++
 3 files changed, 72 insertions(+)

diff --git a/doc/admin-guide/plugins/ts_lua.en.rst b/doc/admin-guide/plugins/ts_lua.en.rst
index 7c8027a..9794ffc 100644
--- a/doc/admin-guide/plugins/ts_lua.en.rst
+++ b/doc/admin-guide/plugins/ts_lua.en.rst
@@ -131,6 +131,22 @@ is always available within lua script. This package can be introduced into Lua l
 
 `TOP <#ts-lua-plugin>`_
 
+ts.process_id
+-------------
+**syntax:** *val = ts.process_id()*
+
+**context:** global
+
+**description:** This function returns the global process id.
+
+Here is an example:
+
+::
+
+    local pid = ts.process_id()  -- a436bae6-082c-4805-86af-78a5916c4a91
+
+`TOP <#ts-lua-plugin>`_
+
 ts.now
 ------
 **syntax:** *val = ts.now()*
@@ -2100,6 +2116,26 @@ This function is usually called in do_global_read_request function
 
 `TOP <#ts-lua-plugin>`_
 
+ts.http.id
+----------
+**syntax:** *ts.http.id()*
+
+**context:** do_remap/do_os_response or do_global_* or later
+
+**description:** This function can be used to tell id of a transaction
+
+Here is an example:
+
+::
+
+    function do_global_read_request()
+        local id = ts.http.id()
+        ts.debug(id)
+        return 0
+    end
+
+`TOP <#ts-lua-plugin>`_
+
 ts.http.is_internal_request
 ---------------------------
 **syntax:** *ts.http.is_internal_request()*
diff --git a/plugins/experimental/ts_lua/ts_lua_http.c b/plugins/experimental/ts_lua/ts_lua_http.c
index 2ab7001..4e7cc3e 100644
--- a/plugins/experimental/ts_lua/ts_lua_http.c
+++ b/plugins/experimental/ts_lua/ts_lua_http.c
@@ -86,6 +86,7 @@ static void ts_lua_inject_cache_lookup_result_variables(lua_State *L);
 static int ts_lua_http_resp_cache_transformed(lua_State *L);
 static int ts_lua_http_resp_cache_untransformed(lua_State *L);
 
+static int ts_lua_http_get_id(lua_State *L);
 static int ts_lua_http_is_internal_request(lua_State *L);
 static int ts_lua_http_skip_remapping_set(lua_State *L);
 static int ts_lua_http_transaction_count(lua_State *L);
@@ -186,6 +187,9 @@ ts_lua_inject_http_resp_transform_api(lua_State *L)
 static void
 ts_lua_inject_http_misc_api(lua_State *L)
 {
+  lua_pushcfunction(L, ts_lua_http_get_id);
+  lua_setfield(L, -2, "id");
+
   lua_pushcfunction(L, ts_lua_http_is_internal_request);
   lua_setfield(L, -2, "is_internal_request");
 
@@ -522,6 +526,19 @@ ts_lua_http_resp_cache_untransformed(lua_State *L)
 }
 
 static int
+ts_lua_http_get_id(lua_State *L)
+{
+  ts_lua_http_ctx *http_ctx;
+
+  GET_HTTP_CONTEXT(http_ctx, L);
+
+  uint64_t id = TSHttpTxnIdGet(http_ctx->txnp);
+  lua_pushnumber(L, id);
+
+  return 1;
+}
+
+static int
 ts_lua_http_is_internal_request(lua_State *L)
 {
   ts_lua_http_ctx *http_ctx;
diff --git a/plugins/experimental/ts_lua/ts_lua_misc.c b/plugins/experimental/ts_lua/ts_lua_misc.c
index b3481dc..e82e1ca 100644
--- a/plugins/experimental/ts_lua/ts_lua_misc.c
+++ b/plugins/experimental/ts_lua/ts_lua_misc.c
@@ -18,6 +18,7 @@
 
 #include "ts_lua_util.h"
 
+static int ts_lua_get_process_id(lua_State *L);
 static int ts_lua_get_now_time(lua_State *L);
 static int ts_lua_debug(lua_State *L);
 static int ts_lua_error(lua_State *L);
@@ -33,6 +34,10 @@ static void ts_lua_inject_misc_variables(lua_State *L);
 void
 ts_lua_inject_misc_api(lua_State *L)
 {
+  /* ts.process_id() */
+  lua_pushcfunction(L, ts_lua_get_process_id);
+  lua_setfield(L, -2, "process_id");
+
   /* ts.now() */
   lua_pushcfunction(L, ts_lua_get_now_time);
   lua_setfield(L, -2, "now");
@@ -66,6 +71,20 @@ ts_lua_inject_misc_variables(lua_State *L)
 }
 
 static int
+ts_lua_get_process_id(lua_State *L)
+{
+  const char *s;
+  TSUuid process = TSProcessUuidGet();
+  if (process) {
+    s = TSUuidStringGet(process);
+  } else {
+    s = "";
+  }
+  lua_pushstring(L, s);
+  return 1;
+}
+
+static int
 ts_lua_get_now_time(lua_State *L)
 {
   lua_Number now;

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.