Skip to content

Commit 59b8959

Browse files
committed
documentation: add detailed description of the queue initialization
1 parent 596558b commit 59b8959

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ align="right">
2222
* [Fields of the space associated with each queue](#fields-of-the-space-associated-with-each-queue)
2323
* [Installing](#installing)
2424
* [Using the queue module](#using-the-queue-module)
25+
* [Initialization](#initialization)
2526
* [Creating a new queue](#creating-a-new-queue)
2627
* [Putting a task in a queue](#putting-a-task-in-a-queue)
2728
* [Taking a task from the queue ("consuming")](#taking-a-task-from-the-queue-consuming)
@@ -302,14 +303,28 @@ build and install.
302303

303304
# Using the `queue` module
304305

306+
## Initialization
305307
```lua
306308
queue = require 'queue'
307309
```
308310

309311
The request "require 'queue'" causes automatic creation of
310312
the `_queue` space, unless it already exists. The same request
311313
also sets the necessary space triggers and other objects
312-
associated with queues.
314+
associated with queues.
315+
If the instance hasn't been configured yet (`box.cfg()` hasn't been called),
316+
the initialization of the queue module will be deferred until the instance will
317+
be configured ("lazy start"). For a good work of the queue, it's necessary to
318+
run the instance in rw mode. If the instance run in ro mode, the initialization
319+
of the queue will be deferred until the instance will be configured in rw mode.
320+
After the instance has been started in rw mode and the queue has been
321+
initialized, it's a bad idea to switch it to ro mode. In the case, an attempt to
322+
do something with a persistent ("temporary" option set to false) queue will fail
323+
(a temporary queue will work fine). In addition, in the case of mode has been
324+
switched, triggers may fail (`_on_consumer_disconnect` for example), which may
325+
cause an inconsistent state of the queue. As for the core drivers that use
326+
background fibers (fifottl, limfifottl, utubettl) - they check the instance mode
327+
on each iteration and will wait until the instance will be switched to rw mode.
313328

314329
## Creating a new queue
315330

0 commit comments

Comments
 (0)