Explorar o código

modules: readme files regenerated - async ... [skip ci]

Kamailio Dev %!s(int64=6) %!d(string=hai) anos
pai
achega
2a94f7e69b
Modificáronse 1 ficheiros con 112 adicións e 16 borrados
  1. 112 16
      src/modules/async/README

+ 112 - 16
src/modules/async/README

@@ -26,20 +26,26 @@ Daniel-Constantin Mierla
         3. Parameters
         3. Parameters
 
 
               3.1. workers (int)
               3.1. workers (int)
+              3.2. ms_timer (int)
 
 
         4. Functions
         4. Functions
 
 
               4.1. async_route(routename, seconds)
               4.1. async_route(routename, seconds)
-              4.2. async_sleep(seconds)
-              4.3. async_task_route(routename)
+              4.2. async_ms_route(routename, milliseconds)
+              4.3. async_sleep(seconds)
+              4.4. async_ms_sleep(milliseconds)
+              4.5. async_task_route(routename)
 
 
    List of Examples
    List of Examples
 
 
    1.1. Set workers parameter
    1.1. Set workers parameter
-   1.2. async_route usage
-   1.3. async_sleep usage
-   1.4. async_workers usage
-   1.5. async_task_route usage
+   1.2. Set ms_timer parameter
+   1.3. async_route usage
+   1.4. async_ms_route usage
+   1.5. async_sleep usage
+   1.6. async_ms_sleep usage
+   1.7. async_workers usage
+   1.8. async_task_route usage
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -54,12 +60,15 @@ Chapter 1. Admin Guide
    3. Parameters
    3. Parameters
 
 
         3.1. workers (int)
         3.1. workers (int)
+        3.2. ms_timer (int)
 
 
    4. Functions
    4. Functions
 
 
         4.1. async_route(routename, seconds)
         4.1. async_route(routename, seconds)
-        4.2. async_sleep(seconds)
-        4.3. async_task_route(routename)
+        4.2. async_ms_route(routename, milliseconds)
+        4.3. async_sleep(seconds)
+        4.4. async_ms_sleep(milliseconds)
+        4.5. async_task_route(routename)
 
 
 1. Overview
 1. Overview
 
 
@@ -94,6 +103,7 @@ Chapter 1. Admin Guide
 3. Parameters
 3. Parameters
 
 
    3.1. workers (int)
    3.1. workers (int)
+   3.2. ms_timer (int)
 
 
 3.1. workers (int)
 3.1. workers (int)
 
 
@@ -107,11 +117,27 @@ Chapter 1. Admin Guide
 modparam("async", "workers", 2)
 modparam("async", "workers", 2)
 ...
 ...
 
 
+3.2. ms_timer (int)
+
+   Enables millisecond timer for async_ms_sleep() and async_ms_route()
+   functions. The integer value is the timer resolution in milliseconds.
+   ms_timer = 1 enables 1 millisecond timer but generates higher load on
+   the system. ms_timer = 20 enables 20 ms timer.
+
+   Default value is 0.
+
+   Example 1.2. Set ms_timer parameter
+...
+modparam("async", "ms_timer", 1)
+...
+
 4. Functions
 4. Functions
 
 
    4.1. async_route(routename, seconds)
    4.1. async_route(routename, seconds)
-   4.2. async_sleep(seconds)
-   4.3. async_task_route(routename)
+   4.2. async_ms_route(routename, milliseconds)
+   4.3. async_sleep(seconds)
+   4.4. async_ms_sleep(milliseconds)
+   4.5. async_task_route(routename)
 
 
 4.1.  async_route(routename, seconds)
 4.1.  async_route(routename, seconds)
 
 
@@ -134,7 +160,7 @@ modparam("async", "workers", 2)
 
 
    This function can be used from REQUEST_ROUTE.
    This function can be used from REQUEST_ROUTE.
 
 
-   Example 1.2. async_route usage
+   Example 1.3. async_route usage
 ...
 ...
 request_route {
 request_route {
     ...
     ...
@@ -147,7 +173,42 @@ route[RESUME] {
 }
 }
 ...
 ...
 
 
-4.2.  async_sleep(seconds)
+4.2.  async_ms_route(routename, milliseconds)
+
+   Simulate a sleep of 'milliseconds' and then continue the processing of
+   the SIP request with the route[routename]. In case of internal errors,
+   the function returns false, otherwise the function exits the execution
+   of the script at that moment (return 0 behaviour). This function works
+   only if the ms_timer parameter has a value greater then 0.
+
+   The routename parameter can be a static string or a dynamic string
+   value with config variables.
+
+   The sleep parameter represent the number of milliseconds to suspend the
+   processing of a SIP request. Maximum value is 30000 (30 sec). The
+   parameter can be a static integer or a variable holding an integer.
+
+   Since the SIP request handling is resumed in another process, the
+   config file execution state is practically lost. Therefore beware that
+   the execution of config after resume will end once the route[routename]
+   is finished.
+
+   This function can be used from REQUEST_ROUTE.
+
+   Example 1.4. async_ms_route usage
+...
+request_route {
+    ...
+    async_ms_route("RESUME", "250");
+    ...
+}
+route[RESUME] {
+   send_reply("404", "Not found");
+   exit;
+}
+...
+
+4.3.  async_sleep(seconds)
 
 
    Simulate a sleep of 'seconds' and then continue the processing of SIP
    Simulate a sleep of 'seconds' and then continue the processing of SIP
    request with the next action. In case of internal errors, the function
    request with the next action. In case of internal errors, the function
@@ -159,14 +220,49 @@ route[RESUME] {
 
 
    This function can be used from REQUEST_ROUTE.
    This function can be used from REQUEST_ROUTE.
 
 
-   Example 1.3. async_sleep usage
+   Example 1.5. async_sleep usage
 ...
 ...
 async_sleep("4");
 async_sleep("4");
 send_reply("404", "Not found");
 send_reply("404", "Not found");
 exit;
 exit;
 ...
 ...
 
 
-4.3.  async_task_route(routename)
+4.4.  async_ms_sleep(milliseconds)
+
+   Simulate a sleep of 'milliseconds' and then continue the processing of
+   SIP request with the next action. In case of internal errors, the
+   function returns false. This function works only if the ms_timer
+   parameter has a value greater then 0.
+
+   The sleep parameter represent the number of milliseconds to suspend the
+   processing of SIP request. Maximum value is 30000 (30 sec). The
+   parameter can be a static integer or a variable holding an integer.
+
+   This function can be used from REQUEST_ROUTE.
+
+   Example 1.6. async_ms_sleep usage
+...
+route[REQUESTSHAPER] {
+        $var(res) = http_connect("leakybucket",
+                                 "/add?key=$fd", $null, $null,"$avp(delay)");
+        $var(d) = $(avp(delay){s.int});
+        if ($var(d) > 0) {
+                # Delay the request by $avp(delay) ms
+                async_ms_sleep("$var(d)");
+                if (!t_relay()) {
+                        sl_reply_error();
+                }
+                exit;
+        }
+        # No delay
+        if (!t_relay()) {
+                sl_reply_error();
+        }
+        exit;
+}
+...
+
+4.5.  async_task_route(routename)
 
 
    Continue the processing of the SIP request with the route[routename] in
    Continue the processing of the SIP request with the route[routename] in
    one of the processes from core asynchronous framework. The core
    one of the processes from core asynchronous framework. The core
@@ -178,7 +274,7 @@ exit;
    async_workers core parameter in the configuration file. See the core
    async_workers core parameter in the configuration file. See the core
    cookbook for more information.
    cookbook for more information.
 
 
-   Example 1.4. async_workers usage
+   Example 1.7. async_workers usage
 ...
 ...
 # Enable 8 worker processes used by async and other modules
 # Enable 8 worker processes used by async and other modules
 async_workers=8
 async_workers=8
@@ -198,7 +294,7 @@ async_workers=8
 
 
    This function can be used from REQUEST_ROUTE.
    This function can be used from REQUEST_ROUTE.
 
 
-   Example 1.5. async_task_route usage
+   Example 1.8. async_task_route usage
 ...
 ...
 request_route {
 request_route {
     ...
     ...