Skip to content

Commit a11dfb2

Browse files
committed
Add examples of syntax for specifying severl URIs; add notes for box.cfg.listen and box.cfg.replication description
Part of #2492
1 parent c8553ee commit a11dfb2

File tree

3 files changed

+81
-27
lines changed

3 files changed

+81
-27
lines changed

doc/reference/configuration/cfg_basic.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,29 @@
6161
.. confval:: listen
6262

6363
Since version 1.6.4.
64+
6465
The read/write data port number or :ref:`URI <index-uri>` (Universal
6566
Resource Identifier) string. Has no default value, so **must be specified**
66-
if connections will occur from remote clients that do not use the
67-
:ref:`admin port <admin-security>`. Connections made with
67+
if connections occur from the remote clients that don't use the
68+
:ref:`"admin port" <admin-security>`. Connections made with
6869
:samp:`listen = {URI}` are called "binary port" or "binary protocol"
6970
connections.
7071

7172
A typical value is 3301.
7273

73-
.. NOTE::
74+
.. code-block:: lua
75+
76+
box.cfg { listen = 3301 }
77+
78+
box.cfg { listen = "127.0.0.1:3301" }
79+
80+
.. NOTE::
7481

7582
A replica also binds to this port, and accepts connections, but these
7683
connections can only serve reads until the replica becomes a master.
7784

85+
Starting from version 2.10.0, you can specify :ref:`several URIs <index-uri-several>`.
86+
7887
| Type: integer or string
7988
| Default: null
8089
| Dynamic: yes

doc/reference/configuration/cfg_replication.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@
3232

3333
:extsamp:`box.cfg{ replication = { {*{'uri1'}*}, {*{'uri2'}*} } }`
3434

35-
If one of the URIs is "self" -- that is, if one of the URIs is for the
36-
instance where ``box.cfg{}`` is being executed on -- then it is ignored.
37-
Thus it is possible to use the same ``replication`` specification on
35+
.. note::
36+
37+
Starting from version 2.10.0, there is a number of other ways for specifying several URIs. See :ref:`syntax examples <index-uri-several>`.
38+
39+
If one of the URIs is "self"---that is, if one of the URIs is for the
40+
instance where ``box.cfg{}`` is being executed on---then it is ignored.
41+
Thus, it is possible to use the same ``replication`` specification on
3842
multiple server instances, as shown in
3943
:ref:`these examples <replication-bootstrap>`.
4044

doc/reference/configuration/index.rst

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,25 @@ Command options
6969
URI
7070
--------------------------------------------------------------------------------
7171

72-
Some configuration parameters and some functions depend on a URI, or
73-
"Universal Resource Identifier". The URI string format is similar to the
72+
Some configuration parameters and some functions depend on a URI (Universal Resource Identifier).
73+
The URI string format is similar to the
7474
`generic syntax for a URI schema <https://en.wikipedia.org/wiki/List_of_URI_schemes>`_.
75-
So it may contain (in order) a user name
76-
for login, a password, a host name or host IP address, and a port number. Only
77-
the port number is always mandatory. The password is mandatory if the user
75+
It may contain (in order):
76+
77+
* user name for login
78+
* password
79+
* host name or host IP address
80+
* port number.
81+
82+
Only a port number is always mandatory. A password is mandatory if a user
7883
name is specified, unless the user name is 'guest'.
7984

8085
Formally, the URI
8186
syntax is ``[host:]port`` or ``[username:password@]host:port``.
82-
If host is omitted, then '0.0.0.0' or '[::]' is assumed,
83-
meaning respectively any IPv4 address or any IPv6 address,
87+
If host is omitted, then "0.0.0.0" or "[::]" is assumed
88+
meaning respectively any IPv4 address or any IPv6 address
8489
on the local machine.
85-
If ``username:password`` is omitted, then 'guest' is assumed. Some examples:
90+
If ``username:password`` is omitted, then the "guest" user is assumed. Some examples:
8691

8792
.. container:: table
8893

@@ -99,40 +104,76 @@ If ``username:password`` is omitted, then 'guest' is assumed. Some examples:
99104
| username:password@host:port | notguest:[email protected]:3301 |
100105
+-----------------------------+------------------------------+
101106

107+
In code, the URI value can be passed as a number (if only a port is specified) or a string:
108+
109+
.. code-block:: lua
110+
111+
box.cfg { listen = 3301 }
112+
113+
box.cfg { listen = "127.0.0.1:3301" }
114+
102115
In certain circumstances, a Unix domain socket may be used
103116
where a URI is expected, for example, "unix/:/tmp/unix_domain_socket.sock" or
104117
simply "/tmp/unix_domain_socket.sock".
105118

119+
A method for parsing URIs is illustrated in :ref:`Module uri <uri-parse>`.
120+
121+
.. _index-uri-several:
122+
123+
Specifying several URIs
124+
~~~~~~~~~~~~~~~~~~~~~~~
125+
106126
Starting from version 2.10.0, a user can open several listening iproto sockets on a Tarantool instance
107-
and, consequently, can specify several URIs in the configuration parameters such as :ref:`box.cfg.listen <cfg_basic-listen>` and :ref:`box.cfg.replication <cfg_replication-replication>`.
127+
and, consequently, can specify several URIs in the configuration parameters
128+
such as :ref:`box.cfg.listen <cfg_basic-listen>` and :ref:`box.cfg.replication <cfg_replication-replication>`.
108129

109-
In addition to specifying URI as a number or a string, a number of other ways to pass URI values is available starting from Tarantool 2.10.0:
130+
URI values can be set in a number of ways:
110131

111-
* As a string with one or several URIs separated by commas (provides backward compatibility)
132+
* As a string with URI values separated by commas
112133

113-
code-block:: lua
134+
.. code-block:: lua
114135
115-
box.cfg { listen = "127.0.0.1:3301, /unix.sock, 3302" }
136+
box.cfg { listen = "127.0.0.1:3301, /unix.sock, 3302" }
116137
117138
* As an array that contains URIs in a string format
118139

119-
code-block:: lua
140+
.. code-block:: lua
120141
121-
box.cfg { listen = {"127.0.0.1:3301", "/unix.sock", "3302"} }
142+
box.cfg { listen = {"127.0.0.1:3301", "/unix.sock", "3302"} }
122143
123144
* As an array of tables with the ``uri`` field
124145

125-
code-block:: lua
146+
.. code-block:: lua
126147
127-
box.cfg { listen = {
128-
{uri = "127.0.0.1:3301"},
129-
{uri = "/unix.sock"},
130-
{uri = 3302}
148+
box.cfg { listen = {
149+
{uri = "127.0.0.1:3301"},
150+
{uri = "/unix.sock"},
151+
{uri = 3302}
152+
}
131153
}
154+
155+
Also, you can specify additional URI parameters. The recommended syntax:
156+
157+
.. code-block:: lua
158+
159+
box.cfg { listen = {
160+
{uri = "127.0.0.1:3301", params = {param1 = "value1"}},
161+
{uri = "/unix.sock", params = {param2 = "value2"}},
162+
{uri = 3302, params = {param3 = "value3"}}
132163
}
164+
}
133165

166+
In case of a single URI, the following syntax also works:
134167

135-
A method for parsing URIs is illustrated in :ref:`Module uri <uri-parse>`.
168+
.. code-block:: lua
169+
170+
box.cfg { listen = {
171+
uri = "127.0.0.1:3301",
172+
params = {
173+
param1 = "value1",
174+
param2 = "value2"
175+
}
176+
}}
136177
137178
.. _index-init_label:
138179

0 commit comments

Comments
 (0)