@@ -109,16 +109,22 @@ import (
109
109
" context"
110
110
" fmt"
111
111
" time"
112
-
112
+
113
113
" github.com/tarantool/go-tarantool/v2"
114
114
)
115
115
116
116
func main () {
117
- opts := tarantool.Opts {User: " guest" }
118
- ctx , cancel := context.WithTimeout (context.Background (),
117
+ ctx , cancel := context.WithTimeout (context.Background (),
119
118
500 * time.Millisecond )
120
119
defer cancel ()
121
- conn , err := tarantool.Connect (ctx, " 127.0.0.1:3301" , opts)
120
+ dialer := tarantool.NetDialer {
121
+ Address: " 127.0.0.1:3301" ,
122
+ User: " guest" ,
123
+ }
124
+ opts := tarantool.Opts {
125
+ Timeout: time.Second ,
126
+ }
127
+ conn , err := tarantool.Connect (ctx, dialer, opts)
122
128
if err != nil {
123
129
fmt.Println (" Connection refused:" , err)
124
130
}
@@ -135,27 +141,30 @@ func main() {
135
141
** Observation 1:** The line "` github.com/tarantool/go-tarantool/v2 ` " in the
136
142
` import(...) ` section brings in all Tarantool-related functions and structures.
137
143
138
- ** Observation 2:** The line starting with "` Opts := ` " sets up the options for
144
+ ** Observation 2:** The line starting with "` dialer := ` " creates dialer for
145
+ ` Connect() ` . This structure contains fields required to establish a connection.
146
+
147
+ ** Observation 3:** The line starting with "` opts := ` " sets up the options for
139
148
` Connect() ` . In this example, the structure contains only a single value, the
140
- username . The structure may also contain other settings, see more in
149
+ timeout . The structure may also contain other settings, see more in
141
150
[ documentation] [ godoc-opts-url ] for the "` Opts ` " structure.
142
151
143
- ** Observation 3 :** The line containing "` tarantool.Connect ` " is essential for
152
+ ** Observation 4 :** The line containing "` tarantool.Connect ` " is essential for
144
153
starting a session. There are three parameters:
145
154
146
155
* a context,
147
- * a string with ` host:port ` format ,
156
+ * the dialer that was set up earlier ,
148
157
* the option structure that was set up earlier.
149
158
150
- There will be only one attempt to connect. If multiple attempts needed,
151
- "` tarantool.Connect ` " could be placed inside the loop with some timeout
152
- between each try. Example could be found in the [ example_test] ( ./example_test.go ) ,
159
+ There will be only one attempt to connect. If multiple attempts needed,
160
+ "` tarantool.Connect ` " could be placed inside the loop with some timeout
161
+ between each try. Example could be found in the [ example_test] ( ./example_test.go ) ,
153
162
name - ` ExampleConnect_reconnects ` .
154
163
155
- ** Observation 4 :** The ` err ` structure will be ` nil ` if there is no error,
164
+ ** Observation 5 :** The ` err ` structure will be ` nil ` if there is no error,
156
165
otherwise it will have a description which can be retrieved with ` err.Error() ` .
157
166
158
- ** Observation 5 :** The ` Insert ` request, like almost all requests, is preceded
167
+ ** Observation 6 :** The ` Insert ` request, like almost all requests, is preceded
159
168
by the method ` Do ` of object ` conn ` which is the object that was returned
160
169
by ` Connect() ` .
161
170
@@ -182,11 +191,16 @@ The subpackage has been deleted. You could use `pool` instead.
182
191
183
192
* The ` connection_pool ` subpackage has been renamed to ` pool ` .
184
193
* The type ` PoolOpts ` has been renamed to ` Opts ` .
185
- * ` pool.Connect ` now accepts context as first argument, which user may cancel
186
- in process. If it is canceled in progress, an error will be returned.
194
+ * ` pool.Connect ` now accepts context as first argument, which user may cancel
195
+ in process. If it is canceled in progress, an error will be returned.
187
196
All created connections will be closed.
188
- * ` pool.Add ` now accepts context as first argument, which user may cancel in
197
+ * ` pool.Add ` now accepts context as first argument, which user may cancel in
189
198
process.
199
+ * Now you need to pass ` map[string]Dialer ` to the ` pool.Connect ` as the second
200
+ argument, instead of a list of addresses. Each dialer is associated with a
201
+ unique string ID, which allows them to be distinguished.
202
+ * ` pool.GetPoolInfo ` has been renamed to ` pool.GetInfo ` . Return type has been changed
203
+ to ` map[string]ConnectionInfo ` .
190
204
191
205
#### crud package
192
206
@@ -235,23 +249,28 @@ IPROTO constants have been moved to a separate package [go-iproto](https://githu
235
249
* ` Op ` struct for update operations made private.
236
250
* Removed ` OpSplice ` struct.
237
251
* ` Operations.Splice ` method now accepts 5 arguments instead of 3.
238
- * Requests ` Update ` , ` UpdateAsync ` , ` UpdateTyped ` , ` Upsert ` , ` UpsertAsync ` no
252
+ * Requests ` Update ` , ` UpdateAsync ` , ` UpdateTyped ` , ` Upsert ` , ` UpsertAsync ` no
239
253
longer accept ` ops ` argument (operations) as an ` interface{} ` . ` *Operations `
240
254
needs to be passed instead.
241
255
* ` UpdateRequest ` and ` UpsertRequest ` structs no longer accept ` interface{} `
242
256
for an ` ops ` field. ` *Operations ` needs to be used instead.
243
257
244
258
#### Connect function
245
259
246
- ` connection.Connect ` no longer return non-working connection objects. This function
260
+ ` connection.Connect ` no longer return non-working connection objects. This function
247
261
now does not attempt to reconnect and tries to establish a connection only once.
248
- Function might be canceled via context. Context accepted as first argument,
262
+ Function might be canceled via context. Context accepted as first argument,
249
263
and user may cancel it in process.
250
264
265
+ Now you need to pass ` Dialer ` as the second argument instead of URI.
266
+ If you were using a non-SSL connection, you need to create ` NetDialer ` .
267
+ For SSL-enabled connections, use ` OpenSslDialer ` . Please note that the options
268
+ for creating a connection are now stored in corresponding ` Dialer ` , not in ` Opts ` .
269
+
251
270
#### Connection schema
252
271
253
- * Removed ` Schema ` field from the ` Connection ` struct. Instead, new
254
- ` GetSchema(Connector) ` function was added to get the actual connection
272
+ * Removed ` Schema ` field from the ` Connection ` struct. Instead, new
273
+ ` GetSchema(Connector) ` function was added to get the actual connection
255
274
schema on demand.
256
275
* ` OverrideSchema(*Schema) ` method replaced with the ` SetSchema(Schema) ` .
257
276
@@ -262,9 +281,9 @@ schema on demand.
262
281
263
282
#### Schema changes
264
283
265
- * ` ResolveSpaceIndex ` function for ` SchemaResolver ` interface split into two:
266
- ` ResolveSpace ` and ` ResolveIndex ` . ` NamesUseSupported ` function added into the
267
- interface to get information if the usage of space and index names in requests
284
+ * ` ResolveSpaceIndex ` function for ` SchemaResolver ` interface split into two:
285
+ ` ResolveSpace ` and ` ResolveIndex ` . ` NamesUseSupported ` function added into the
286
+ interface to get information if the usage of space and index names in requests
268
287
is supported.
269
288
* ` Schema ` structure no longer implements ` SchemaResolver ` interface.
270
289
* ` Spaces ` and ` SpacesById ` fields of the ` Schema ` struct store spaces by value.
0 commit comments