# HG changeset patch # User Yaroslav Zhuravlev # Date 1694550762 -3600 # Node ID 4470b2bff7b77987ade4a4eaa0d4c01f210c18df # Parent 3184864bbb3fbce414d41bf4afac2518912d5e73 Documented the js_periodic directive. diff --git a/xml/en/docs/http/ngx_http_js_module.xml b/xml/en/docs/http/ngx_http_js_module.xml --- a/xml/en/docs/http/ngx_http_js_module.xml +++ b/xml/en/docs/http/ngx_http_js_module.xml @@ -9,7 +9,7 @@ + rev="42">
@@ -539,6 +539,80 @@ since + +function | + module.function + [interval=time] + [jitter=number] + [worker_affinity=mask] + +location +if in location +limit_except +0.8.1 + + +Specifies a content handler to run at regular interval. +The handler receives a session object as its first argument, +it also has access to global objects such as +ngx. + + + +The optional interval parameter +sets the interval between two consecutive runs, +by default, 5 seconds. + + + +The optional jitter parameter sets the time within which +the location content handler will be randomly delayed, +by default, there is no delay. + + + +By default, the js_handler is executed on worker process 0. +The optional worker_affinity parameter +allows specifying particular worker processes +where the location content handler should be executed. +Each worker process set is represented by a bitmask of allowed worker processes. +The all mask allows the handler to be executed +in all worker processes. + + + +Example: + +example.conf: + +location @periodics { + # to be run at 1 minute intervals in worker process 0 + js_periodic main.handler interval=60s; + + # to be run at 1 minute intervals in all worker processes + js_periodic main.handler interval=60s worker_affinity=all; + + # to be run at 1 minute intervals in worker processes 1 and 3 + js_periodic main.handler interval=60s worker_affinity=0101; + + resolver 10.0.0.1; + js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem; +} + +example.js: + +async function handler(s) { + let reply = async ngx.fetch('https://nginx.org/en/docs/njs/'); + let body = async reply.text(); + + ngx.log(ngx.INFO, body); +} + + + + + + name.json | name from file.json @@ -659,7 +733,7 @@ key-value pair when the zone storage is -Examples: +Example: example.conf: # Creates a 1Mb dictionary with string values, diff --git a/xml/en/docs/stream/ngx_stream_js_module.xml b/xml/en/docs/stream/ngx_stream_js_module.xml --- a/xml/en/docs/stream/ngx_stream_js_module.xml +++ b/xml/en/docs/stream/ngx_stream_js_module.xml @@ -9,7 +9,7 @@ + rev="41">
@@ -458,6 +458,78 @@ since + +function | + module.function + [interval=time] + [jitter=number] + [worker_affinity=mask] + +server +0.8.1 + + +Specifies a content handler to run at regular interval. +The handler receives a session object as its first argument, +it also has access to global objects such as +ngx. + + + +The optional interval parameter +sets the interval between two consecutive runs, +by default, 5 seconds. + + + +The optional jitter parameter sets the time within which +the location content handler will be randomly delayed, +by default, there is no delay. + + + +By default, the js_handler is executed on worker process 0. +The optional worker_affinity parameter +allows specifying particular worker processes +where the location content handler should be executed. +Each worker process set is represented by a bitmask of allowed worker processes. +The all mask allows the handler to be executed +in all worker processes. + + + +Example: + +example.conf: + +location @periodics { + # to be run at 1 minute intervals in worker process 0 + js_periodic main.handler interval=60s; + + # to be run at 1 minute intervals in all worker processes + js_periodic main.handler interval=60s worker_affinity=all; + + # to be run at 1 minute intervals in worker processes 1 and 3 + js_periodic main.handler interval=60s worker_affinity=0101; + + resolver 10.0.0.1; + js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem; +} + +example.js: + +async function handler(s) { + let reply = async ngx.fetch('https://nginx.org/en/docs/njs/'); + let body = async reply.text(); + + ngx.log(ngx.INFO, body); +} + + + + + + name.json | name from file.json @@ -644,7 +716,7 @@ key-value pair when the zone storage is -Examples: +Example: example.conf: # Creates a 1Mb dictionary with string values, diff --git a/xml/ru/docs/http/ngx_http_js_module.xml b/xml/ru/docs/http/ngx_http_js_module.xml --- a/xml/ru/docs/http/ngx_http_js_module.xml +++ b/xml/ru/docs/http/ngx_http_js_module.xml @@ -9,7 +9,7 @@ + rev="42">
@@ -540,6 +540,82 @@ function version(r) { + +функция | + модуль.функция + [interval=время] + [jitter=число] + [worker_affinity=маска] + +location +if in location +limit_except +0.8.1 + + +Задаёт периодичность запуска обработчика содержимого. +В качестве первого аргумента обработчик получает объект сессии, +также у обработчика есть доступ к глобальным объектам таким как +ngx. + + + +Необязательный параметр interval +задаёт интервал между двумя последовательными запусками, +по умолчанию 5 секунд. + + + +Необязательный параметр jitter +задаёт время, в пределах которого +случайным образом задерживается каждый запуск, +по умолчанию задержки нет. + + + +По умолчанию js_handler выполняется для рабочего процесса 0. +Необязательный параметр worker_affinity +позволяет указать рабочий процесс, +для которого будет выполняться обработчик содержимого location. +Рабочие процессы задаются битовой маской разрешённых к использованию рабочих +процессов. +Маска all позволяет обработчику выполняться +для всех рабочих процессов. + + + +Пример: + +example.conf: + +location @periodics { + # интервал выполнения 1 минута для рабочего процесса 0 + js_periodic main.handler interval=60s; + + # интервал выполнения 1 минута для всех рабочих процессов + js_periodic main.handler interval=60s worker_affinity=all; + + # интервал выполнения 1 минута для рабочих процессов 1 и 3 + js_periodic main.handler interval=60s worker_affinity=0101; + + resolver 10.0.0.1; + js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem; +} + +example.js: + +async function handler(s) { + let reply = async ngx.fetch('https://nginx.org/en/docs/njs/'); + let body = async reply.text(); + + ngx.log(ngx.INFO, body); +} + + + + + + имя.json | имя from файл.json diff --git a/xml/ru/docs/stream/ngx_stream_js_module.xml b/xml/ru/docs/stream/ngx_stream_js_module.xml --- a/xml/ru/docs/stream/ngx_stream_js_module.xml +++ b/xml/ru/docs/stream/ngx_stream_js_module.xml @@ -9,7 +9,7 @@ + rev="40">
@@ -555,6 +555,80 @@ js_preload_object map.json; + +функция | + модуль.функция + [interval=время] + [jitter=число] + [worker_affinity=маска] + +server +0.8.1 + + +Задаёт периодичность запуска обработчика содержимого. +В качестве первого аргумента обработчик получает объект сессии, +также у обработчика есть доступ к глобальным объектам таким как +ngx. + + + +Необязательный параметр interval +задаёт интервал между двумя последовательными запусками, +по умолчанию 5 секунд. + + + +Необязательный параметр jitter +задаёт время, в пределах которого +случайным образом задерживается каждый запуск, +по умолчанию задержки нет. + + + +По умолчанию js_handler выполняется для рабочего процесса 0. +Необязательный параметр worker_affinity +позволяет указать рабочий процесс, +для которого будет выполняться обработчик содержимого location. +Рабочие процессы задаются битовой маской разрешённых к использованию рабочих +процессов. +Маска all позволяет обработчику выполняться +для всех рабочих процессов. + + + +Пример: + +example.conf: + +location @periodics { + # интервал выполнения 1 минута для рабочего процесса 0 + js_periodic main.handler interval=60s; + + # интервал выполнения 1 минута для всех рабочих процессов + js_periodic main.handler interval=60s worker_affinity=all; + + # интервал выполнения 1 минута для рабочих процессов 1 и 3 + js_periodic main.handler interval=60s worker_affinity=0101; + + resolver 10.0.0.1; + js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem; +} + +example.js: + +async function handler(s) { + let reply = async ngx.fetch('https://nginx.org/en/docs/njs/'); + let body = async reply.text(); + + ngx.log(ngx.INFO, body); +} + + + + + + $переменная функция |