Skip to content

Commit

Permalink
api: remove NewErrorFuture
Browse files Browse the repository at this point in the history
It was introduced in e9b9ba1 . The function looks strange in the
public API. The patch moves it to the connection_pool's internal
implementation.
  • Loading branch information
oleg-jukovec committed Jun 27, 2022
1 parent 61d0739 commit 0fd6c03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- `IPROTO_*` constants that identify requests renamed from `<Name>Request` to
`<Name>RequestCode` (#126)

### Removed

- NewErrorFuture function (#190)

### Fixed

## [1.6.0] - 2022-06-01
Expand Down
28 changes: 17 additions & 11 deletions connection_pool/connection_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (connPool *ConnectionPool) EvalTyped(expr string, args interface{}, result
func (connPool *ConnectionPool) SelectAsync(space, index interface{}, offset, limit, iterator uint32, key interface{}, userMode ...Mode) *tarantool.Future {
conn, err := connPool.getConnByMode(ANY, userMode)
if err != nil {
return tarantool.NewErrorFuture(err)
return newErrorFuture(err)
}

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

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

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

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

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

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

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

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

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

return conn.EvalAsync(expr, args)
Expand Down Expand Up @@ -548,7 +548,7 @@ func (connPool *ConnectionPool) DoTyped(req tarantool.Request, result interface{
func (connPool *ConnectionPool) DoAsync(req tarantool.Request, userMode Mode) *tarantool.Future {
conn, err := connPool.getNextConnection(userMode)
if err != nil {
return tarantool.NewErrorFuture(err)
return newErrorFuture(err)
}

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

return connPool.getNextConnection(mode)
}

func newErrorFuture(err error) *tarantool.Future {
fut := tarantool.NewFuture()
fut.SetError(err)
return fut
}
7 changes: 0 additions & 7 deletions future.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ func NewFuture() (fut *Future) {
return fut
}

// NewErrorFuture returns new set empty Future with filled error field.
func NewErrorFuture(err error) *Future {
fut := NewFuture()
fut.SetError(err)
return fut
}

// AppendPush appends the push response to the future.
// Note: it works only before SetResponse() or SetError()
func (fut *Future) AppendPush(resp *Response) {
Expand Down

0 comments on commit 0fd6c03

Please sign in to comment.