• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / go-tarantool / 6717080327

01 Nov 2023 07:46AM UTC coverage: 79.395% (+0.01%) from 79.383%
6717080327

Pull #343

github

DifferentialOrange
crud: change timeout option type

`Timeout` is an option supported for all crud operations using
VShard API. In Lua, timeout has `number` type, so float values are
allowed. Float timeouts can be useful to set the timeout less than
a second. After this patch, `Timeout` will be an optional float64
instead of an optional int.

This is a breaking change.

CRUD allows to use negative timeouts. This approach does not make any
sense for an operation: for example, initial schema fetch will fail.
Since the module itself does not check for a negative value argument,
we do not forbid it here too.

Closes #342
Pull Request #343: crud: change timeout option type

9 of 9 new or added lines in 1 file covered. (100.0%)

5487 of 6911 relevant lines covered (79.4%)

7901.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/errors.go
1
package tarantool
2

3
import (
4
        "fmt"
5

6
        "github.com/tarantool/go-iproto"
7
)
8

9
// Error is wrapper around error returned by Tarantool.
10
type Error struct {
11
        Code         iproto.Error
12
        Msg          string
13
        ExtendedInfo *BoxError
14
}
15

16
// Error converts an Error to a string.
17
func (tnterr Error) Error() string {
4✔
18
        if tnterr.ExtendedInfo != nil {
8✔
19
                return tnterr.ExtendedInfo.Error()
4✔
20
        }
4✔
21

22
        return fmt.Sprintf("%s (0x%x)", tnterr.Msg, tnterr.Code)
×
23
}
24

25
// ClientError is connection error produced by this client,
26
// i.e. connection failures or timeouts.
27
type ClientError struct {
28
        Code uint32
29
        Msg  string
30
}
31

32
// Error converts a ClientError to a string.
33
func (clierr ClientError) Error() string {
14✔
34
        return fmt.Sprintf("%s (0x%x)", clierr.Msg, clierr.Code)
14✔
35
}
14✔
36

37
// Temporary returns true if next attempt to perform request may succeeded.
38
//
39
// Currently it returns true when:
40
//
41
// - Connection is not connected at the moment
42
//
43
// - request is timeouted
44
//
45
// - request is aborted due to rate limit
46
func (clierr ClientError) Temporary() bool {
×
47
        switch clierr.Code {
×
48
        case ErrConnectionNotReady, ErrTimeouted, ErrRateLimited, ErrIoError:
×
49
                return true
×
50
        default:
×
51
                return false
×
52
        }
53
}
54

55
// Tarantool client error codes.
56
const (
57
        ErrConnectionNotReady = 0x4000 + iota
58
        ErrConnectionClosed   = 0x4000 + iota
59
        ErrProtocolError      = 0x4000 + iota
60
        ErrTimeouted          = 0x4000 + iota
61
        ErrRateLimited        = 0x4000 + iota
62
        ErrConnectionShutdown = 0x4000 + iota
63
        ErrIoError            = 0x4000 + iota
64
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc