Skip to content

Commit b7e46a7

Browse files
Experimental 'connpool' module (#4153)
1 parent 3b51c8b commit b7e46a7

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

doc/release/3.1.0.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,69 @@ The following numeric types are added:
159159
* ``float64``: a 64-bit floating point number.
160160

161161

162+
.. _3-1-experimental_connpool:
163+
164+
Experimental 'connpool' module
165+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166+
167+
A new ``experimental.connpool`` :ref:`module <built_in_modules>` provides a set of features for remote connections to any cluster instance or executing remote procedure calls on an instance that meets the specified criteria.
168+
To load the ``experimental.connpool`` module, use the ``require()`` directive:
169+
170+
.. code-block:: tarantoolsession
171+
172+
sharded_cluster:router-a-001> connpool = require('experimental.connpool')
173+
---
174+
...
175+
176+
In the 3.1 version, this module provides the following API:
177+
178+
* The ``connect()`` function accepts an instance name and returns the active connection to this instance:
179+
180+
.. code-block:: tarantoolsession
181+
182+
sharded_cluster:router-a-001> conn = connpool.connect("storage-b-002")
183+
---
184+
...
185+
186+
Once you have a connection, you can execute requests on a remote instance, for example, select data from a space:
187+
188+
.. code-block:: tarantoolsession
189+
190+
sharded_cluster:router-a-001> conn.space.bands:select({}, { limit = 5 })
191+
---
192+
- - [3, 804, 'Ace of Base', 1987]
193+
- [7, 693, 'The Doors', 1965]
194+
- [9, 644, 'Led Zeppelin', 1968]
195+
- [10, 569, 'Queen', 1970]
196+
...
197+
198+
199+
* The ``filter()`` function returns the names of instances that match the specified conditions.
200+
In the example below, this function returns a list of instances with the ``storage`` role and specified label value:
201+
202+
.. code-block:: tarantoolsession
203+
204+
sharded_cluster:router-a-001> connpool.filter({ roles = { 'storage' }, labels = { dc = 'east' }})
205+
---
206+
- - storage-b-002
207+
- storage-a-002
208+
...
209+
210+
* The ``call()`` function can be used to execute a function on a remote instance.
211+
In the example below, the following conditions are specified to choose an instance to execute the ``vshard.storage.buckets_count`` function on:
212+
213+
* An instance has the ``storage`` role.
214+
* An instance has the ``dc`` label set to ``west``.
215+
* An instance is writable.
216+
217+
.. code-block:: tarantoolsession
218+
219+
sharded_cluster:router-a-001> connpool.call('vshard.storage.buckets_count', nil, { roles = { 'storage' }, labels = { dc = 'west' }, mode = 'rw' })
220+
---
221+
- 500
222+
...
223+
224+
162225
163226
.. _3-1-accessing_configuration:
164227

0 commit comments

Comments
 (0)