Skip to content

Commit 0f3cf4d

Browse files
committed
api: remove NewErrorFuture from the public API
It was introduced in e9b9ba1 . This function looks strange in the public API. The patch moves it to the connection_pool's internal implementation.
1 parent 61d0739 commit 0f3cf4d

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
2323
- `IPROTO_*` constants that identify requests renamed from `<Name>Request` to
2424
`<Name>RequestCode` (#126)
2525

26+
### Removed
27+
28+
- NewErrorFuture(err) call (#190)
29+
2630
### Fixed
2731

2832
## [1.6.0] - 2022-06-01

connection_pool/connection_pool.go

+17-11
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func (connPool *ConnectionPool) EvalTyped(expr string, args interface{}, result
416416
func (connPool *ConnectionPool) SelectAsync(space, index interface{}, offset, limit, iterator uint32, key interface{}, userMode ...Mode) *tarantool.Future {
417417
conn, err := connPool.getConnByMode(ANY, userMode)
418418
if err != nil {
419-
return tarantool.NewErrorFuture(err)
419+
return newErrorFuture(err)
420420
}
421421

422422
return conn.SelectAsync(space, index, offset, limit, iterator, key)
@@ -427,7 +427,7 @@ func (connPool *ConnectionPool) SelectAsync(space, index interface{}, offset, li
427427
func (connPool *ConnectionPool) InsertAsync(space interface{}, tuple interface{}, userMode ...Mode) *tarantool.Future {
428428
conn, err := connPool.getConnByMode(RW, userMode)
429429
if err != nil {
430-
return tarantool.NewErrorFuture(err)
430+
return newErrorFuture(err)
431431
}
432432

433433
return conn.InsertAsync(space, tuple)
@@ -438,7 +438,7 @@ func (connPool *ConnectionPool) InsertAsync(space interface{}, tuple interface{}
438438
func (connPool *ConnectionPool) ReplaceAsync(space interface{}, tuple interface{}, userMode ...Mode) *tarantool.Future {
439439
conn, err := connPool.getConnByMode(RW, userMode)
440440
if err != nil {
441-
return tarantool.NewErrorFuture(err)
441+
return newErrorFuture(err)
442442
}
443443

444444
return conn.ReplaceAsync(space, tuple)
@@ -449,7 +449,7 @@ func (connPool *ConnectionPool) ReplaceAsync(space interface{}, tuple interface{
449449
func (connPool *ConnectionPool) DeleteAsync(space, index interface{}, key interface{}, userMode ...Mode) *tarantool.Future {
450450
conn, err := connPool.getConnByMode(RW, userMode)
451451
if err != nil {
452-
return tarantool.NewErrorFuture(err)
452+
return newErrorFuture(err)
453453
}
454454

455455
return conn.DeleteAsync(space, index, key)
@@ -460,7 +460,7 @@ func (connPool *ConnectionPool) DeleteAsync(space, index interface{}, key interf
460460
func (connPool *ConnectionPool) UpdateAsync(space, index interface{}, key, ops interface{}, userMode ...Mode) *tarantool.Future {
461461
conn, err := connPool.getConnByMode(RW, userMode)
462462
if err != nil {
463-
return tarantool.NewErrorFuture(err)
463+
return newErrorFuture(err)
464464
}
465465

466466
return conn.UpdateAsync(space, index, key, ops)
@@ -471,7 +471,7 @@ func (connPool *ConnectionPool) UpdateAsync(space, index interface{}, key, ops i
471471
func (connPool *ConnectionPool) UpsertAsync(space interface{}, tuple interface{}, ops interface{}, userMode ...Mode) *tarantool.Future {
472472
conn, err := connPool.getConnByMode(RW, userMode)
473473
if err != nil {
474-
return tarantool.NewErrorFuture(err)
474+
return newErrorFuture(err)
475475
}
476476

477477
return conn.UpsertAsync(space, tuple, ops)
@@ -484,7 +484,7 @@ func (connPool *ConnectionPool) UpsertAsync(space interface{}, tuple interface{}
484484
func (connPool *ConnectionPool) CallAsync(functionName string, args interface{}, userMode Mode) *tarantool.Future {
485485
conn, err := connPool.getNextConnection(userMode)
486486
if err != nil {
487-
return tarantool.NewErrorFuture(err)
487+
return newErrorFuture(err)
488488
}
489489

490490
return conn.CallAsync(functionName, args)
@@ -496,7 +496,7 @@ func (connPool *ConnectionPool) CallAsync(functionName string, args interface{},
496496
func (connPool *ConnectionPool) Call16Async(functionName string, args interface{}, userMode Mode) *tarantool.Future {
497497
conn, err := connPool.getNextConnection(userMode)
498498
if err != nil {
499-
return tarantool.NewErrorFuture(err)
499+
return newErrorFuture(err)
500500
}
501501

502502
return conn.Call16Async(functionName, args)
@@ -508,7 +508,7 @@ func (connPool *ConnectionPool) Call16Async(functionName string, args interface{
508508
func (connPool *ConnectionPool) Call17Async(functionName string, args interface{}, userMode Mode) *tarantool.Future {
509509
conn, err := connPool.getNextConnection(userMode)
510510
if err != nil {
511-
return tarantool.NewErrorFuture(err)
511+
return newErrorFuture(err)
512512
}
513513

514514
return conn.Call17Async(functionName, args)
@@ -518,7 +518,7 @@ func (connPool *ConnectionPool) Call17Async(functionName string, args interface{
518518
func (connPool *ConnectionPool) EvalAsync(expr string, args interface{}, userMode Mode) *tarantool.Future {
519519
conn, err := connPool.getNextConnection(userMode)
520520
if err != nil {
521-
return tarantool.NewErrorFuture(err)
521+
return newErrorFuture(err)
522522
}
523523

524524
return conn.EvalAsync(expr, args)
@@ -548,7 +548,7 @@ func (connPool *ConnectionPool) DoTyped(req tarantool.Request, result interface{
548548
func (connPool *ConnectionPool) DoAsync(req tarantool.Request, userMode Mode) *tarantool.Future {
549549
conn, err := connPool.getNextConnection(userMode)
550550
if err != nil {
551-
return tarantool.NewErrorFuture(err)
551+
return newErrorFuture(err)
552552
}
553553

554554
return conn.DoAsync(req)
@@ -802,3 +802,9 @@ func (connPool *ConnectionPool) getConnByMode(defaultMode Mode, userMode []Mode)
802802

803803
return connPool.getNextConnection(mode)
804804
}
805+
806+
func newErrorFuture(err error) *tarantool.Future {
807+
fut := tarantool.NewFuture()
808+
fut.SetError(err)
809+
return fut
810+
}

future.go

-7
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,6 @@ func NewFuture() (fut *Future) {
126126
return fut
127127
}
128128

129-
// NewErrorFuture returns new set empty Future with filled error field.
130-
func NewErrorFuture(err error) *Future {
131-
fut := NewFuture()
132-
fut.SetError(err)
133-
return fut
134-
}
135-
136129
// AppendPush appends the push response to the future.
137130
// Note: it works only before SetResponse() or SetError()
138131
func (fut *Future) AppendPush(resp *Response) {

0 commit comments

Comments
 (0)