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

tarantool / go-tarantool / 13930913017

18 Mar 2025 06:33PM UTC coverage: 75.939% (+0.08%) from 75.863%
13930913017

Pull #435

github

maksim.konovalov
pool: Pooler interface supports GetInfo method in TopologyEditor
Pull Request #435: pool: Pooler interface supports GetInfo method in TopologyEditor

2992 of 3940 relevant lines covered (75.94%)

9863.87 hits per line

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

84.62
/protocol.go
1
package tarantool
2

3
import (
4
        "context"
5

6
        "github.com/tarantool/go-iproto"
7
        "github.com/vmihailenco/msgpack/v5"
8
)
9

10
// ProtocolVersion type stores Tarantool protocol version.
11
type ProtocolVersion uint64
12

13
// ProtocolInfo type aggregates Tarantool protocol version and features info.
14
type ProtocolInfo struct {
15
        // Auth is an authentication method.
16
        Auth Auth
17
        // Version is the supported protocol version.
18
        Version ProtocolVersion
19
        // Features are supported protocol features.
20
        Features []iproto.Feature
21
}
22

23
// Clone returns an exact copy of the ProtocolInfo object.
24
// Any changes in copy will not affect the original values.
25
func (info ProtocolInfo) Clone() ProtocolInfo {
343✔
26
        infoCopy := info
343✔
27

343✔
28
        if info.Features != nil {
686✔
29
                infoCopy.Features = make([]iproto.Feature, len(info.Features))
343✔
30
                copy(infoCopy.Features, info.Features)
343✔
31
        }
343✔
32

33
        return infoCopy
343✔
34
}
35

36
var clientProtocolInfo ProtocolInfo = ProtocolInfo{
37
        // Protocol version supported by connector. Version 3
38
        // was introduced in Tarantool 2.10.0, version 4 was
39
        // introduced in master 948e5cd (possible 2.10.5 or 2.11.0).
40
        // Support of protocol version on connector side was introduced in
41
        // 1.10.0.
42
        Version: ProtocolVersion(6),
43
        // Streams and transactions were introduced in protocol version 1
44
        // (Tarantool 2.10.0), in connector since 1.7.0.
45
        // Error extension type was introduced in protocol
46
        // version 2 (Tarantool 2.10.0), in connector since 1.10.0.
47
        // Watchers were introduced in protocol version 3 (Tarantool 2.10.0), in
48
        // connector since 1.10.0.
49
        // Pagination were introduced in protocol version 4 (Tarantool 2.11.0), in
50
        // connector since 1.11.0.
51
        // WatchOnce request type was introduces in protocol version 6
52
        // (Tarantool 3.0.0), in connector since 2.0.0.
53
        Features: []iproto.Feature{
54
                iproto.IPROTO_FEATURE_STREAMS,
55
                iproto.IPROTO_FEATURE_TRANSACTIONS,
56
                iproto.IPROTO_FEATURE_ERROR_EXTENSION,
57
                iproto.IPROTO_FEATURE_WATCHERS,
58
                iproto.IPROTO_FEATURE_PAGINATION,
59
                iproto.IPROTO_FEATURE_SPACE_AND_INDEX_NAMES,
60
                iproto.IPROTO_FEATURE_WATCH_ONCE,
61
        },
62
}
63

64
// IdRequest informs the server about supported protocol
65
// version and protocol features.
66
type IdRequest struct {
67
        baseRequest
68
        protocolInfo ProtocolInfo
69
}
70

71
func fillId(enc *msgpack.Encoder, protocolInfo ProtocolInfo) error {
327✔
72
        enc.EncodeMapLen(2)
327✔
73

327✔
74
        enc.EncodeUint(uint64(iproto.IPROTO_VERSION))
327✔
75
        if err := enc.Encode(protocolInfo.Version); err != nil {
327✔
76
                return err
×
77
        }
×
78

79
        enc.EncodeUint(uint64(iproto.IPROTO_FEATURES))
327✔
80

327✔
81
        t := len(protocolInfo.Features)
327✔
82
        if err := enc.EncodeArrayLen(t); err != nil {
327✔
83
                return err
×
84
        }
×
85

86
        for _, feature := range protocolInfo.Features {
2,604✔
87
                if err := enc.Encode(feature); err != nil {
2,277✔
88
                        return err
×
89
                }
×
90
        }
91

92
        return nil
327✔
93
}
94

95
// NewIdRequest returns a new IdRequest.
96
func NewIdRequest(protocolInfo ProtocolInfo) *IdRequest {
334✔
97
        req := new(IdRequest)
334✔
98
        req.rtype = iproto.IPROTO_ID
334✔
99
        req.protocolInfo = protocolInfo.Clone()
334✔
100
        return req
334✔
101
}
334✔
102

103
// Body fills an msgpack.Encoder with the id request body.
104
func (req *IdRequest) Body(res SchemaResolver, enc *msgpack.Encoder) error {
327✔
105
        return fillId(enc, req.protocolInfo)
327✔
106
}
327✔
107

108
// Context sets a passed context to the request.
109
//
110
// Pay attention that when using context with request objects,
111
// the timeout option for Connection does not affect the lifetime
112
// of the request. For those purposes use context.WithTimeout() as
113
// the root context.
114
func (req *IdRequest) Context(ctx context.Context) *IdRequest {
3✔
115
        req.ctx = ctx
3✔
116
        return req
3✔
117
}
3✔
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