@@ -109,16 +109,22 @@ import (
109109 " context"
110110 " fmt"
111111 " time"
112-
112+
113113 " github.com/tarantool/go-tarantool/v2"
114114)
115115
116116func main () {
117- opts := tarantool.Opts {User: " guest" }
118- ctx , cancel := context.WithTimeout (context.Background (),
117+ dialer := tarantool.NetDialer {
118+ Address: " 127.0.0.1:3301" ,
119+ User: " guest" ,
120+ }
121+ opts := tarantool.Opts {
122+ Timeout: time.Second ,
123+ }
124+ ctx , cancel := context.WithTimeout (context.Background (),
119125 500 * time.Millisecond )
120126 defer cancel ()
121- conn , err := tarantool.Connect (ctx, " 127.0.0.1:3301 " , opts)
127+ conn , err := tarantool.Connect (ctx, dialer , opts)
122128 if err != nil {
123129 fmt.Println (" Connection refused:" , err)
124130 }
@@ -135,27 +141,30 @@ func main() {
135141** Observation 1:** The line "` github.com/tarantool/go-tarantool/v2 ` " in the
136142` import(...) ` section brings in all Tarantool-related functions and structures.
137143
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
139148` 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
141150[ documentation] [ godoc-opts-url ] for the "` Opts ` " structure.
142151
143- ** Observation 3 :** The line containing "` tarantool.Connect ` " is essential for
152+ ** Observation 4 :** The line containing "` tarantool.Connect ` " is essential for
144153starting a session. There are three parameters:
145154
146155* a context,
147- * a string with ` host:port ` format ,
156+ * a dialer that was set up earlier ,
148157* the option structure that was set up earlier.
149158
150159There will be only one attempt to connect. If multiple attempts needed,
151160"` tarantool.Connect ` " could be placed inside the loop with some timeout
152161between each try. Example could be found in the [ example_test] ( ./example_test.go ) ,
153162name - ` ExampleConnect_reconnects ` .
154163
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,
156165otherwise it will have a description which can be retrieved with ` err.Error() ` .
157166
158- ** Observation 5 :** The ` Insert ` request, like almost all requests, is preceded
167+ ** Observation 6 :** The ` Insert ` request, like almost all requests, is preceded
159168by the method ` Do ` of object ` conn ` which is the object that was returned
160169by ` Connect() ` .
161170
@@ -187,6 +196,11 @@ The subpackage has been deleted. You could use `pool` instead.
187196 All created connections will be closed.
188197* ` pool.Add ` now accepts context as first argument, which user may cancel in
189198 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 ` .
190204
191205#### crud package
192206
@@ -248,6 +262,11 @@ now does not attempt to reconnect and tries to establish a connection only once.
248262Function might be canceled via context. Context accepted as first argument,
249263and user may cancel it in process.
250264
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+
251270#### Protocol changes
252271
253272* ` iproto.Feature ` type used instead of ` ProtocolFeature ` .
0 commit comments