Skip to content

Commit a76f6d1

Browse files
committed
docs: update according to the changes
1 parent 1096f66 commit a76f6d1

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,22 @@ import (
109109
"context"
110110
"fmt"
111111
"time"
112-
112+
113113
"github.com/tarantool/go-tarantool/v2"
114114
)
115115

116116
func main() {
117-
opts := tarantool.Opts{User: "guest"}
118-
ctx, cancel := context.WithTimeout(context.Background(),
117+
dialer := tarantool.TtDialer {
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
144153
starting 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

150159
There will be only one attempt to connect. If multiple attempts needed,
151160
"`tarantool.Connect`" could be placed inside the loop with some timeout
152161
between each try. Example could be found in the [example_test](./example_test.go),
153162
name - `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,
156165
otherwise 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
159168
by the method `Do` of object `conn` which is the object that was returned
160169
by `Connect()`.
161170

@@ -187,6 +196,9 @@ 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.
190202

191203
#### crud package
192204

@@ -248,6 +260,11 @@ now does not attempt to reconnect and tries to establish a connection only once.
248260
Function might be canceled via context. Context accepted as first argument,
249261
and user may cancel it in process.
250262

263+
Now you need to pass `Dialer` as the second argument instead of URI.
264+
If you were using a non-SSL connection, you need to create `TtDialer`.
265+
For SSL-enabled connections, use `OpenSslDialer`. Please note that the options
266+
for creating a connection are now stored in corresponding `Dialer`, not in `Opts`.
267+
251268
#### Protocol changes
252269

253270
* `iproto.Feature` type used instead of `ProtocolFeature`.

0 commit comments

Comments
 (0)