Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool: add Instance type #373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- Change `OverrideSchema(*Schema)` to `SetSchema(Schema)` (#7)
- Change values, stored by pointers in the `Schema`, `Space`, `Index` structs,
to be stored by their values (#7)
- Make `Dialer` mandatory for creation a single connection / connection pool (#321)
- Make `Dialer` mandatory for creation a single connection (#321)
- Remove `Connection.RemoteAddr()`, `Connection.LocalAddr()`.
Add `Addr()` function instead (#321)
- Remove `Connection.ClientProtocolInfo`, `Connection.ServerProtocolInfo`.
Expand Down Expand Up @@ -93,6 +93,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
`Call`, `Call16`, `Call17`, `Eval`, `Execute` of a `Connector` and `Pooler`
return response data instead of an actual responses (#237)
- Renamed `StrangerResponse` to `MockResponse` (#237)
- `pool.Connect`, `pool.ConnetcWithOpts` and `pool.Add` use a new type
`pool.Instance` to determinate connection options (#356)

### Deprecated

Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,19 @@ The subpackage has been deleted. You could use `pool` instead.

* The `connection_pool` subpackage has been renamed to `pool`.
* The type `PoolOpts` has been renamed to `Opts`.
* `pool.Connect` now accepts context as first argument, which user may cancel
in process. If it is canceled in progress, an error will be returned.
All created connections will be closed.
* `pool.Add` now accepts context as first argument, which user may cancel in
process.
* Now you need to pass `map[string]Dialer` to the `pool.Connect` as the second
argument, instead of a list of addresses. Each dialer is associated with a
unique string ID, which allows them to be distinguished.
* `pool.GetPoolInfo` has been renamed to `pool.GetInfo`. Return type has been changed
to `map[string]ConnectionInfo`.
* `pool.Connect` and `pool.ConnectWithOpts` now accept context as the first
argument, which user may cancel in process. If it is canceled in progress,
an error will be returned and all created connections will be closed.
* `pool.Connect` and `pool.ConnectWithOpts` now accept `[]pool.Instance` as
the second argument instead of a list of addresses. Each instance is
associated with a unique string name, `Dialer` and connection options which
allows instances to be independently configured.
* `pool.Add` now accepts context as the first argument, which user may cancel
in process.
* `pool.Add` now accepts `pool.Instance` as the second argument instead of
an address, it allows to configure a new instance more flexible.
* `pool.GetPoolInfo` has been renamed to `pool.GetInfo`. Return type has been
changed to `map[string]ConnectionInfo`.
* Operations `Ping`, `Select`, `Insert`, `Replace`, `Delete`, `Update`, `Upsert`,
`Call`, `Call16`, `Call17`, `Eval`, `Execute` of a `Pooler` return
response data instead of an actual responses.
Expand Down
6 changes: 4 additions & 2 deletions dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (m *mockIoConn) Read(b []byte) (int, error) {

ret, err := m.readbuf.Read(b)

if m.read != nil {
if ret != 0 && m.read != nil {
m.read <- struct{}{}
}

Expand Down Expand Up @@ -282,15 +282,17 @@ func TestConn_ReadWrite(t *testing.T) {
0x01, 0xce, 0x00, 0x00, 0x00, 0x02,
0x80, // Body map.
})
conn.Close()
})
defer func() {
dialer.conn.writeWg.Done()
conn.Close()
}()

fut := conn.Do(tarantool.NewPingRequest())

<-dialer.conn.written
dialer.conn.written = nil

dialer.conn.readWg.Done()
<-dialer.conn.read
<-dialer.conn.read
Expand Down
Loading
Loading