Skip to content

Commit b2b800b

Browse files
askaltoleg-jukovec
authored andcommitted
doc: update according to the changes
Closes #321
1 parent 10a5ccc commit b2b800b

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

README.md

+43-24
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+
ctx, cancel := context.WithTimeout(context.Background(),
119118
500 * time.Millisecond)
120119
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)
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+
* the dialer that was set up earlier,
148157
* the option structure that was set up earlier.
149158

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),
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

@@ -182,11 +191,16 @@ The subpackage has been deleted. You could use `pool` instead.
182191

183192
* The `connection_pool` subpackage has been renamed to `pool`.
184193
* 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.
187196
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
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

@@ -235,23 +249,28 @@ IPROTO constants have been moved to a separate package [go-iproto](https://githu
235249
* `Op` struct for update operations made private.
236250
* Removed `OpSplice` struct.
237251
* `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
239253
longer accept `ops` argument (operations) as an `interface{}`. `*Operations`
240254
needs to be passed instead.
241255
* `UpdateRequest` and `UpsertRequest` structs no longer accept `interface{}`
242256
for an `ops` field. `*Operations` needs to be used instead.
243257

244258
#### Connect function
245259

246-
`connection.Connect` no longer return non-working connection objects. This function
260+
`connection.Connect` no longer return non-working connection objects. This function
247261
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,
249263
and 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
#### Connection schema
252271

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
255274
schema on demand.
256275
* `OverrideSchema(*Schema)` method replaced with the `SetSchema(Schema)`.
257276

@@ -262,9 +281,9 @@ schema on demand.
262281

263282
#### Schema changes
264283

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
268287
is supported.
269288
* `Schema` structure no longer implements `SchemaResolver` interface.
270289
* `Spaces` and `SpacesById` fields of the `Schema` struct store spaces by value.

0 commit comments

Comments
 (0)