File tree 1 file changed +19
-4
lines changed
1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 9
9
"io"
10
10
"net"
11
11
"net/url"
12
+ "regexp"
12
13
"strings"
13
14
"sync"
14
15
"sync/atomic"
21
22
ErrSyncFailed = errors .New ("SYNC failed" )
22
23
23
24
versionPrefix = []byte ("Tarantool " )
25
+
26
+ greetingRegexp = regexp .MustCompile ("^Tarantool ([0-9.]+) [(]([^ ]+)[)] ([a-f0-9-]+)" )
24
27
)
25
28
26
29
type Options struct {
@@ -42,8 +45,9 @@ type Options struct {
42
45
}
43
46
44
47
type Greeting struct {
45
- Version uint32
46
- Auth []byte
48
+ Version uint32
49
+ InstanceUUID string
50
+ Auth []byte
47
51
}
48
52
49
53
type Connection struct {
@@ -277,9 +281,16 @@ func parseGreeting(r io.Reader) (*Greeting, error) {
277
281
return nil , err
278
282
}
279
283
284
+ uuid := ""
285
+ m := greetingRegexp .FindAllSubmatch (greeting [:64 ], - 1 )
286
+ if len (m ) > 0 && len (m [0 ]) > 3 {
287
+ uuid = string (m [0 ][3 ])
288
+ }
289
+
280
290
return & Greeting {
281
- Version : version ,
282
- Auth : greeting [64 :108 ],
291
+ Version : version ,
292
+ Auth : greeting [64 :108 ],
293
+ InstanceUUID : uuid ,
283
294
}, nil
284
295
}
285
296
@@ -453,6 +464,10 @@ func (conn *Connection) IsClosed() bool {
453
464
}
454
465
}
455
466
467
+ func (conn * Connection ) InstanceUUID () string {
468
+ return conn .greeting .InstanceUUID
469
+ }
470
+
456
471
func (conn * Connection ) releasePacket (pp * BinaryPacket ) {
457
472
if conn .poolMaxPacketSize == 0 || conn .poolMaxPacketSize < cap (pp .body ) {
458
473
pp .Release ()
You can’t perform that action at this time.
0 commit comments