@@ -86,74 +86,61 @@ On this diagram:
86
86
87
87
Below is a list of all ``net.box `` functions.
88
88
89
- .. container :: table
90
-
91
- .. rst-class :: left-align-column-1
92
- .. rst-class :: left-align-column-2
93
-
94
- +----------------------------------------------------+---------------------------+
95
- | Name | Use |
96
- +====================================================+===========================+
97
- | :ref: `net_box.connect() | |
98
- | <net_box-connect>` |br | | Create a connection |
99
- | :ref: `net_box.new() | |
100
- | <net_box-new>` |br | | |
101
- | :ref: `net_box.self <net_box-self >` | |
102
- +----------------------------------------------------+---------------------------+
103
- | :ref: `conn:ping() | Execute a PING command |
104
- | <conn-ping>` | |
105
- +----------------------------------------------------+---------------------------+
106
- | :ref: `conn:wait_connected() | Wait for a connection to |
107
- | <conn-wait_connected>` | be active or closed |
108
- +----------------------------------------------------+---------------------------+
109
- | :ref: `conn:is_connected() | Check if a connection |
110
- | <conn-is_connected>` | is active or closed |
111
- +----------------------------------------------------+---------------------------+
112
- | :ref: `conn:wait_state() | Wait for a target state |
113
- | <conn-wait_state>` | |
114
- +----------------------------------------------------+---------------------------+
115
- | :ref: `conn:close() | Close a connection |
116
- | <conn-close>` | |
117
- +----------------------------------------------------+---------------------------+
118
- | :ref: `conn.space.space-name:select{field-value} | Select one or more tuples |
119
- | <conn-select>` | |
120
- +----------------------------------------------------+---------------------------+
121
- | :ref: `conn.space.space-name:get{field-value} | Select a tuple |
122
- | <conn-get>` | |
123
- +----------------------------------------------------+---------------------------+
124
- | :ref: `conn.space.space-name:insert{field-value} | Insert a tuple |
125
- | <conn-insert>` | |
126
- +----------------------------------------------------+---------------------------+
127
- | :ref: `conn.space.space-name:replace{field-value} | Insert or replace a tuple |
128
- | <conn-replace>` | |
129
- +----------------------------------------------------+---------------------------+
130
- | :ref: `conn.space.space-name:update{field-value} | Update a tuple |
131
- | <conn-update>` | |
132
- +----------------------------------------------------+---------------------------+
133
- | :ref: `conn.space.space-name:upsert{field-value} | Update a tuple |
134
- | <conn-upsert>` | |
135
- +----------------------------------------------------+---------------------------+
136
- | :ref: `conn.space.space-name:delete{field-value} | Delete a tuple |
137
- | <conn-delete>` | |
138
- +----------------------------------------------------+---------------------------+
139
- | :ref: `conn:eval() | Evaluate and execute the |
140
- | <net_box-eval>` | expression in a string |
141
- +----------------------------------------------------+---------------------------+
142
- | :ref: `conn:call() | Call a stored procedure |
143
- | <net_box-call>` | |
144
- +----------------------------------------------------+---------------------------+
145
- | :ref: `conn:timeout() | Set a timeout |
146
- | <conn-timeout>` | |
147
- +----------------------------------------------------+---------------------------+
148
- | :ref: `conn:on_connect() | Define a connect |
149
- | <net_box-on_connect>` | trigger |
150
- +----------------------------------------------------+---------------------------+
151
- | :ref: `conn:on_disconnect() | Define a disconnect |
152
- | <net_box-on_disconnect>` | trigger |
153
- +----------------------------------------------------+---------------------------+
154
- | :ref: `conn:on_schema_reload() | Define a trigger when |
155
- | <net_box-on_schema_reload>` | schema is modified |
156
- +----------------------------------------------------+---------------------------+
89
+ .. container :: table
90
+
91
+ .. list-table ::
92
+ :widths: 50 50
93
+ :header-rows: 1
94
+
95
+ * - Name
96
+ - Use
97
+ * - :ref: `net_box.connect() <net_box-connect >` |br | :ref: `net_box.new() <net_box-new >` |br | :ref: `net_box.self <net_box-self >`
98
+ - Create a connection
99
+ * - :ref: `conn:ping() <conn-ping >`
100
+ - Execute a PING command
101
+ * - :ref: `conn:wait_connected() <conn-wait_connected >`
102
+ - Wait for a connection to be active or closed
103
+ * - :ref: `conn:is_connected() <conn-is_connected >`
104
+ - Check if a connection is active or closed
105
+ * - :ref: `conn:wait_state() <conn-wait_state >`
106
+ - Wait for a target state
107
+ * - :ref: `conn:close() <conn-close >`
108
+ - Close a connection
109
+ * - :ref: `conn.space.space-name:select{field-value} <conn-select >`
110
+ - Select one or more tuples
111
+ * - :ref: `conn.space.space-name:get{field-value} <conn-get >`
112
+ - Select a tuple
113
+ * - :ref: `conn.space.space-name:insert{field-value} <conn-insert >`
114
+ - Insert a tuple
115
+ * - :ref: `conn.space.space-name:replace{field-value} <conn-replace >`
116
+ - Insert or replace a tuple
117
+ * - :ref: `conn.space.space-name:update{field-value} <conn-update >`
118
+ - Update a tuple
119
+ * - :ref: `conn.space.space-name:upsert{field-value} <conn-upsert >`
120
+ - Update a tuple
121
+ * - :ref: `conn.space.space-name:delete{field-value} <conn-delete >`
122
+ - Delete a tuple
123
+ * - :ref: `conn:eval() <net_box-eval >`
124
+ - Evaluate the expression in a string and execute it
125
+ * - :ref: `conn:call() <net_box-call >`
126
+ - Call a stored procedure
127
+ * - :ref: `conn:timeout() <conn-timeout >`
128
+ - Set a timeout
129
+ * - :ref: `conn:on_connect() <net_box-on_connect >`
130
+ - Define a connect trigger
131
+ * - :ref: `conn:on_disconnect() <net_box-on_disconnect >`
132
+ - Define a disconnect trigger
133
+ * - :ref: `conn:on_schema_reload() <net_box-on_schema_reload >`
134
+ - Define a trigger when schema is modified
135
+ * - :ref: `conn:new_stream() <conn-new_stream >`
136
+ - Create a stream
137
+ * - :ref: `stream:begin() <net_box-stream_begin >`
138
+ - Begin a stream transaction
139
+ * - :ref: `stream:commit() <net_box-stream_commit >`
140
+ - Commit a stream transaction
141
+ * - :ref: `stream:rollback() <net_box-stream_rollback >`
142
+ - Rollback a stream transaction
143
+
157
144
.. module :: net_box
158
145
159
146
.. _net_box-connect :
@@ -174,7 +161,7 @@ Below is a list of all ``net.box`` functions.
174
161
disconnect (see ``reconnect_after `` option below).
175
162
The returned ``conn `` object supports methods for making remote requests,
176
163
such as select, update or delete.
177
-
164
+
178
165
Possible options:
179
166
180
167
* `user/password `: you have two ways to connect to a remote host:
@@ -635,6 +622,64 @@ Below is a list of all ``net.box`` functions.
635
622
The option can be useful if you want to pass a response through without decoding or with partial decoding.
636
623
The usage of :ref: `MsgPack object <msgpack-object-info >` can reduce pressure on the Lua garbage collector.
637
624
625
+ .. _conn-new_stream :
626
+
627
+ .. method :: stream([options])
628
+
629
+ Create a stream.
630
+
631
+ **Example: **
632
+
633
+ .. code-block :: lua
634
+
635
+ -- Start a server to create a new stream
636
+ local conn = net_box.connect('localhost:3301')
637
+ local conn_space = conn.space.test
638
+ local stream = conn:new_stream()
639
+ local stream_space = stream.space.test
640
+
641
+ .. class :: stream
642
+
643
+ .. _net_box-stream_begin :
644
+
645
+ .. method :: begin()
646
+
647
+ Begin a stream transaction. Instead of the direct method, you can also use the ``call ``, ``eval `` or execute methods with SQL transaction.
648
+
649
+ .. _net_box-stream_commit :
650
+
651
+ .. method :: commit()
652
+
653
+ Commit a stream transaction. Instead of the direct method, you can also use the ``call ``, ``eval `` or execute methods with SQL transaction.
654
+
655
+ **Examples: **
656
+
657
+ .. code-block :: lua
658
+
659
+ -- Begin stream transaction
660
+ stream:begin()
661
+ -- In the previously created ``accounts`` space with the primary key ``test``, modify the fields 2 and 3
662
+ stream.space.accounts:update(test_1, {{'-', 2, 370}, {'+', 3, 100}})
663
+ -- Commit stream transaction
664
+ stream:commit()
665
+
666
+ .. _net_box-stream_rollback :
667
+
668
+ .. method :: rollback()
669
+
670
+ Rollback a stream transaction. Instead of the direct method, you can also use the ``call ``, ``eval `` or execute methods with SQL transaction.
671
+
672
+ **Example: **
673
+
674
+ .. code-block :: lua
675
+
676
+ -- Test rollback for memtx space
677
+ space:replace({1})
678
+ -- Select return tuple that was previously inserted, because this select belongs to stream transaction
679
+ space:select({})
680
+ stream:rollback()
681
+ -- Select is empty, stream transaction rollback
682
+ space:select({})
638
683
639
684
.. _net_box-triggers :
640
685
0 commit comments