@@ -160,29 +160,21 @@ Below is a list of all ``net.box`` functions.
160
160
161
161
.. function :: connect(URI [, {option[s]}])
162
162
163
- The names ``connect() `` and ``new() `` are synonyms: ``connect() `` is
164
- preferred; ``new() `` is retained for backward compatibility. For more
165
- information, see the description of ``net_box.new() `` below.
166
-
167
- .. _net_box-new :
168
-
169
- .. function :: new(URI [, {option[s]}])
170
-
171
163
Create a new connection. The connection is established on demand, at the
172
164
time of the first request. It can be re-established automatically after a
173
165
disconnect (see ``reconnect_after `` option below).
174
166
The returned ``conn `` object supports methods for making remote requests,
175
167
such as select, update or delete.
176
-
168
+
177
169
:param string URI: the :ref: `URI <index-uri >` of the target for the connection
178
170
:param options: the supported options are shown below:
179
-
180
- * ``user/password ``: two options to connect to a remote host other than through
181
- :ref: `URI <index-uri >`. For example, instead of ``connect('username:userpassword@localhost:3301') ``
171
+
172
+ * ``user/password ``: two options to connect to a remote host other than through
173
+ :ref: `URI <index-uri >`. For example, instead of ``connect('username:userpassword@localhost:3301') ``
182
174
you can write ``connect('localhost:3301', {user = 'username', password='userpassword'}) ``.
183
175
184
- * ``wait_connected ``: a connection timeout. By default, the connection is blocked until the connection
185
- is established, but if you specify ``wait_connected=false ``, the connection returns immediately.
176
+ * ``wait_connected ``: a connection timeout. By default, the connection is blocked until the connection
177
+ is established, but if you specify ``wait_connected=false ``, the connection returns immediately.
186
178
If you specify this timeout, it will wait before returning (``wait_connected=1.5 `` makes it wait at most 1.5 seconds).
187
179
188
180
.. NOTE ::
@@ -191,43 +183,44 @@ Below is a list of all ``net.box`` functions.
191
183
The wait completes once the connection is established or is closed explicitly.
192
184
193
185
194
- * ``reconnect_after ``: a number of seconds to wait before reconnecting.
195
- The default value, as with the other ``connect `` options, is ``nil ``. If ``reconnect_after ``
196
- is greater than zero, then a ``net.box `` instance will attempt to reconnect if a connection
197
- is lost or a connection attempt fails. This makes transient network failures transparent to the application.
198
- Reconnection happens automatically in the background, so requests that initially fail due to connection drops
199
- fail, are transparently retried. The number of retries is unlimited, connection retries are made after
200
- any specified interval (for example, ``reconnect_after=5 `` means that reconnect attempts are made every 5 seconds).
201
- When a connection is explicitly closed or when the Lua garbage collector removes it, then reconnect attempts stop.
202
-
186
+ * ``reconnect_after ``: a number of seconds to wait before reconnecting.
187
+ The default value, as with the other ``connect `` options, is ``nil ``. If ``reconnect_after ``
188
+ is greater than zero, then a ``net.box `` instance will attempt to reconnect if a connection
189
+ is lost or a connection attempt fails. This makes transient network failures transparent to the application.
190
+ Reconnection happens automatically in the background, so requests that initially fail due to connection drops
191
+ fail, are transparently retried. The number of retries is unlimited, connection retries are made after
192
+ any specified interval (for example, ``reconnect_after=5 `` means that reconnect attempts are made every 5 seconds).
193
+ When a connection is explicitly closed or when the Lua garbage collector removes it, then reconnect attempts stop.
203
194
204
- * ``call_16 ``: [since 1.7.2] a new binary protocol command for CALL in ``net.box `` connections by default.
205
- The new CALL is not backward compatible with previous versions. It no longer restricts a function to
206
- returning an array of tuples and allows returning an arbitrary MsgPack/JSON result,
207
- including scalars, nil and void (nothing). The old CALL is left intact for backward compatibility.
208
- It will not be present in the next major release. All programming language drivers will gradually be switched
209
- to the new CALL. To connect to a Tarantool instance that uses the old CALL, specify ``call_16=true ``.
210
195
211
- * ``console ``: an option to use different connection support methods (as if instances of different
212
- classes are returned). With ``console = true ``, you can use the ``conn `` methods ``close() ``,
213
- ``is_connected() ``, ``wait_state() ``, ``eval() `` (in this case both binary and Lua console
214
- network protocols are supported).
215
- With ``console = false `` (default), you can also use ``conn `` database methods (in this case only the
216
- binary protocol is supported). Deprecation note: ``console = true `` is deprecated, users should use
217
- :ref: `console.connect() <console-connect >` instead.
196
+ * ``call_16 ``: [since 1.7.2] a new binary protocol command for CALL in ``net.box `` connections by default.
197
+ The new CALL is not backward compatible with previous versions. It no longer restricts a function to
198
+ returning an array of tuples and allows returning an arbitrary MsgPack/JSON result,
199
+ including scalars, nil and void (nothing). The old CALL is left intact for backward compatibility.
200
+ It will not be present in the next major release. All programming language drivers will gradually be switched
201
+ to the new CALL. To connect to a Tarantool instance that uses the old CALL, specify ``call_16=true ``.
218
202
219
203
* ``connect_timeout ``: a number of seconds to wait before returning "error: Connection timed out".
220
204
221
- * ``required_protocol_version ``: a minimum version of the :ref: `IPROTO protocol <box_protocol-id >`
222
- supported by the server. If the version of the :ref: `IPROTO protocol <box_protocol-id >` supported
223
- by the server is lower than specified, the connection will fail with an error message.
224
- With ``required_protocol_version = 1 ``, all connections fail where the :ref: `IPROTO protocol <box_protocol-id >`
225
- version is lower than ``1 ``.
205
+ * ``fetch_schema ``: a boolean option that controls fetching schema changes from the server. Default: ``true ``.
206
+ If you don't operate with remote spaces, for example, run only ``call `` or ``eval ``, set ``fetch_schema `` to
207
+ ``false `` to avoid fetching schema changes which is not needed in this case.
208
+
209
+ .. important ::
210
+
211
+ In connections with ``fetch_schema == false ``, remote spaces are unavailable
212
+ and the :ref: `on_schema_reload <net_box-on_schema_reload >` triggers don't work.
226
213
227
- * ``required_protocol_features ``: specified :ref: `IPROTO protocol features <box_protocol-id >` supported by the server.
228
- You can specify one or more ``net.box `` features from the table below. If the server does not
229
- support the specified features, the connection will fail with an error message.
230
- With ``required_protocol_features = {'transactions'} ``, all connections fail where the
214
+ * ``required_protocol_version ``: a minimum version of the :ref: `IPROTO protocol <box_protocol-id >`
215
+ supported by the server. If the version of the :ref: `IPROTO protocol <box_protocol-id >` supported
216
+ by the server is lower than specified, the connection will fail with an error message.
217
+ With ``required_protocol_version = 1 ``, all connections fail where the :ref: `IPROTO protocol <box_protocol-id >`
218
+ version is lower than ``1 ``.
219
+
220
+ * ``required_protocol_features ``: specified :ref: `IPROTO protocol features <box_protocol-id >` supported by the server.
221
+ You can specify one or more ``net.box `` features from the table below. If the server does not
222
+ support the specified features, the connection will fail with an error message.
223
+ With ``required_protocol_features = {'transactions'} ``, all connections fail where the
231
224
server has ``transactions: false ``.
232
225
233
226
.. container :: table
@@ -240,26 +233,26 @@ Below is a list of all ``net.box`` functions.
240
233
- Use
241
234
- IPROTO feature ID
242
235
- IPROTO versions supporting the feature
243
- * - ``streams ``
236
+ * - ``streams ``
244
237
- Requires streams support on the server
245
- - IPROTO_FEATURE_STREAMS
238
+ - IPROTO_FEATURE_STREAMS
246
239
- 1 and newer
247
240
* - ``transactions ``
248
241
- Requires transactions support on the server
249
- - IPROTO_FEATURE_TRANSACTIONS
242
+ - IPROTO_FEATURE_TRANSACTIONS
250
243
- 1 and newer
251
244
* - ``error_extension ``
252
245
- Requires support for :ref: `MP_ERROR <msgpack_ext-error >` MsgPack extension on the server
253
- - IPROTO_FEATURE_ERROR_EXTENSION
246
+ - IPROTO_FEATURE_ERROR_EXTENSION
254
247
- 2 and newer
255
248
* - ``watchers ``
256
249
- Requires remote :ref: `watchers <conn-watch >` support on the server
257
- - IPROTO_FEATURE_WATCHERS
258
- - 3 and newer
259
-
250
+ - IPROTO_FEATURE_WATCHERS
251
+ - 3 and newer
252
+
260
253
To learn more about IPROTO features, see :ref: `IPROTO_ID <box_protocol-id >`
261
254
and the :ref: `IPROTO_FEATURES <internals-iproto-keys-features >` key.
262
-
255
+
263
256
:return: conn object
264
257
:rtype: userdata
265
258
@@ -268,12 +261,19 @@ Below is a list of all ``net.box`` functions.
268
261
.. code-block :: lua
269
262
270
263
net_box = require('net.box')
271
-
264
+
272
265
conn = net_box.connect('localhost:3301')
273
266
conn = net_box.connect('127.0.0.1:3302', {wait_connected = false})
274
267
conn = net_box.connect('127.0.0.1:3303', {reconnect_after = 5, call_16 = true})
275
268
conn = net_box.connect('127.0.0.1:3304', {required_protocol_version = 4, required_protocol_features = {'transactions', 'streams'}, })
276
269
270
+ .. _net_box-new :
271
+
272
+ .. function :: new(URI [, {option[s]}])
273
+
274
+ ``new() `` is a synonym for ``connect() ``. It is retained for backward compatibility.
275
+ For more information, see the description of :ref: `net_box.connect() <net_box-connect >`.
276
+
277
277
.. _net_box-self :
278
278
279
279
.. class :: self
@@ -562,13 +562,13 @@ Below is a list of all ``net.box`` functions.
562
562
The method has the same syntax as the :doc: `box.watch() </reference/reference_lua/box_events/broadcast >`
563
563
function, which is used for subscribing to events locally.
564
564
565
- Watchers survive reconnection (see the ``reconnect_after `` connection :ref: `option <net_box-new >`).
565
+ Watchers survive reconnection (see the ``reconnect_after `` connection :ref: `option <net_box-connect >`).
566
566
All registered watchers are automatically resubscribed when the
567
567
connection is reestablished.
568
568
569
569
If a remote host supports watchers, the ``watchers `` key will be set in the
570
570
connection ``peer_protocol_features ``.
571
- For details, check the :ref: `net.box features table <net_box-new >`.
571
+ For details, check the :ref: `net.box features table <net_box-connect >`.
572
572
573
573
.. note ::
574
574
@@ -603,28 +603,6 @@ Below is a list of all ``net.box`` functions.
603
603
604
604
w:unregister()
605
605
606
- .. _conn-timeout :
607
-
608
- .. method :: timeout(timeout)
609
-
610
- ``timeout(...) `` is a wrapper which sets a timeout for the request that
611
- follows it. Since version 1.7.4 this method is deprecated -- it is better
612
- to pass a timeout value for a method's ``{options} `` parameter.
613
-
614
- **Example: **
615
-
616
- .. code-block :: lua
617
-
618
- conn:timeout(0.5).space.tester:update({1}, {{'=', 2, 15}})
619
-
620
- Although ``timeout(...) `` is deprecated, all
621
- remote calls support its use. Using a wrapper object makes
622
- the remote connection API compatible with the local one, removing the need
623
- for a separate ``timeout `` argument, which the local version would ignore. Once
624
- a request is sent, it cannot be revoked from the remote server even if a
625
- timeout expires: the timeout expiration only aborts the wait for the remote
626
- server response, not the request itself.
627
-
628
606
.. _net_box-is_async :
629
607
630
608
.. method :: request(... {is_async=...})
0 commit comments