@@ -18,25 +18,27 @@ type OnShutdownCallback func(err error)
18
18
19
19
type IprotoServer struct {
20
20
sync.Mutex
21
- conn net.Conn
22
- reader * bufio.Reader
23
- writer * bufio.Writer
24
- uuid string
25
- salt []byte // base64-encoded salt
26
- ctx context.Context
27
- cancel context.CancelFunc
28
- handler QueryHandler
29
- onShutdown OnShutdownCallback
30
- output chan * BinaryPacket
31
- closeOnce sync.Once
32
- firstError error
33
- perf PerfCount
34
- schemaID uint64
35
- wg sync.WaitGroup
21
+ conn net.Conn
22
+ reader * bufio.Reader
23
+ writer * bufio.Writer
24
+ uuid string
25
+ salt []byte // base64-encoded salt
26
+ ctx context.Context
27
+ cancel context.CancelFunc
28
+ handler QueryHandler
29
+ onShutdown OnShutdownCallback
30
+ output chan * BinaryPacket
31
+ closeOnce sync.Once
32
+ firstError error
33
+ perf PerfCount
34
+ schemaID uint64
35
+ wg sync.WaitGroup
36
+ getPingStatus func (* IprotoServer ) uint
36
37
}
37
38
38
39
type IprotoServerOptions struct {
39
- Perf PerfCount
40
+ Perf PerfCount
41
+ GetPingStatus func (* IprotoServer ) uint
40
42
}
41
43
42
44
func NewIprotoServer (uuid string , handler QueryHandler , onShutdown OnShutdownCallback ) * IprotoServer {
@@ -56,6 +58,10 @@ func (s *IprotoServer) WithOptions(opts *IprotoServerOptions) *IprotoServer {
56
58
opts = & IprotoServerOptions {}
57
59
}
58
60
s .perf = opts .Perf
61
+ s .getPingStatus = opts .GetPingStatus
62
+ if s .getPingStatus == nil {
63
+ s .getPingStatus = func (* IprotoServer ) uint { return 0 }
64
+ }
59
65
return s
60
66
}
61
67
@@ -223,6 +229,7 @@ READER_LOOP:
223
229
code := packet .Cmd
224
230
if code == PingCommand {
225
231
pr := packetPool .GetWithID (packet .requestID )
232
+ pr .packet .Cmd = s .getPingStatus (s )
226
233
pr .packet .SchemaID = packet .SchemaID
227
234
228
235
select {
0 commit comments