# HG changeset patch # User Yaroslav Zhuravlev # Date 1659972582 -3600 # Node ID fd8ec06ceafac30dbf3087c52542879d7e493367 # Parent 0280b6c71d388f0fb535a2c64adfa733156c26ca Improved descriptions of js_access, js_filter, js_preread. 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="32">
@@ -142,6 +142,50 @@ Since + +The function is called once at the moment when the stream session reaches +the access phase +for the first time. +The function is called with the following arguments: + + +s + +the Stream Session object + + + + + + +At this phase, it is possible to perform initialization +or register a callback with +the s.on() +method +for each incoming data chunk until one of the following methods are called: +s.allow(), +s.decline(), +s.done(). +As soon as one of these methods is called, the stream session processing +switches to the next phase +and all current +s.on() +callbacks are dropped. + + + + +As the js_access handler +returns its result immediately, it supports +only synchronous callbacks. +Thus, asynchronous callbacks such as +ngx.fetch() +or +setTimeout() +are not supported. + + + @@ -291,6 +335,42 @@ with 0.4.0, a module function can be referenced. +The filter function is called once at the moment when the stream session reaches +the content phase. + + + +The filter function is called with the following arguments: + +s + +the Stream Session object + + + + + + +At this phase, it is possible to perform initialization +or register a callback with +the s.on() +method for each incoming data chunk. +The +s.off() +method may be used to unregister a callback and stop filtering. + + + + +As the js_filter handler +returns its result immediately, it supports +only synchronous operations. +Thus, asynchronous operations such as +ngx.fetch() +or +setTimeout() +are not supported. + @@ -386,6 +466,58 @@ Since + +The function is called once +at the moment when the stream session reaches the +preread phase +for the first time. +The function is called with the following arguments: + + +s + +the Stream Session object + + + + + + +At this phase, it is possible to perform initialization +or register a callback with +the s.on() +method +for each incoming data chunk until one of the following methods are called: +s.allow(), +s.decline(), +s.done(). +When one of these methods is called, +the stream session switches to the +next phase +and all current +s.on() +callbacks are dropped. + + + + +As the js_preread handler +returns its result immediately, it supports +only synchronous callbacks. +Thus, asynchronous callbacks such as +ngx.fetch() +or +setTimeout() +are not supported. +Nevertheless, asynchronous operations are supported in +s.on() +callbacks in the +preread phase. +See +this example for more information. + + + 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="32">
@@ -142,6 +142,49 @@ export default {bar, preread, req_line, можно ссылаться на функцию модуля. + +Функция вызывается однократно при первом достижении сессией +access-фазы. +Функция вызывается со следующими аргументами: + + +s + +объект stream-сессии + + + + + + +В этой фазе может происходить инициализация, +также при помощи метода +s.on() +может регистрироваться вызов +для каждого входящего блока данных пока не будет вызван один из методов: +s.done() +s.decline(), +s.allow(). +При вызове любого из этих методов обработка сессии +переходит на следующую фазу +и все текущие вызовы +s.on() +сбрасываются. + + + + +Так как обработчик js_access +должен сразу возвращать результат, +то поддерживаются только синхронные операции. +Таким образом, асинхронные операции, например +ngx.fetch() +или +setTimeout(), +не поддерживаются. + + + @@ -292,6 +335,43 @@ HTTPS-сертификата Задаёт фильтр данных. Начиная с 0.4.0 можно ссылаться на функцию модуля. +Функция фильтра вызывается однократно при первом достижении сессией +content-фазы. + + + +Функция фильтра вызывается со следующими аргументами: + +s + +объект stream-сессии + + + + + + +В этой фазе может происходить инициализация, +также при помощи метода +s.on() +может регистрироваться вызов +для каждого входящего блока данных. +Для отмены регистрации вызова и отмены фильтра +можно использовать метод +s.off(). + + + + +Так как обработчик js_filter +должен сразу возвращать результат, +то поддерживаются только синхронные операции. +Таким образом, асинхронные операции, например +ngx.fetch() +или +setTimeout(), +не поддерживаются. + @@ -374,6 +454,55 @@ function address(s) { можно ссылаться на функцию модуля. + +Функция вызывается однократно при первом достижении сессией +preread-фазы. +Функция вызывается со следующими аргументами: + + +s + +объект stream-сессии + + + + + + +В этой фазе может происходить инициализация, +также при помощи метода +s.on() +может регистрироваться вызов +для каждого входящего блока данных пока не будет вызван один из методов: +s.done() +s.decline(), +s.allow(). +При вызове любого из этих методов обработка сессии +переходит на следующую фазу +и все текущие вызовы +s.on() +сбрасываются. + + + + +Так как обработчик js_preread +должен сразу возвращать результат, +то поддерживаются только синхронные операции. +Таким образом, асинхронные операции, например +ngx.fetch() +или +setTimeout(), +не поддерживаются. +Тем не менее асинхронные операции поддерживаются в вызовах +s.on() +в +preread-фазе. +Подробнее см. +пример. + + + @@ -424,11 +553,11 @@ function address(s) { Так как обработчик js_set должен сразу возвращать результат, -то поддерживаются только синхронные вызовы. -Таким образом, асинхронные вызовы, например -ngx.fetch() +то поддерживаются только синхронные операции. +Таким образом, асинхронные операции, например +ngx.fetch() или -setTimeout(), +setTimeout(), не поддерживаются.