[OSS] Add boilerplate for proto files implementing BlockableQuery (#15554)

This commit is contained in:
Chris S. Kim 2022-11-25 15:46:56 -05:00 committed by GitHub
parent e72dd6254a
commit 450c8b9eff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

3
.changelog/_3729.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
namespace: **(Enterprise Only)** Fix a bug that caused blocking queries during namespace replication to timeout
```

View File

@ -595,6 +595,16 @@ func (msg *%[1]s) AllowStaleRead() bool {
return msg.%[2]s.AllowStaleRead() return msg.%[2]s.AllowStaleRead()
} }
// BlockingTimeout implements pool.BlockableQuery
func (msg *%[1]s) BlockingTimeout(maxQueryTime, defaultQueryTime time.Duration) time.Duration {
maxTime := structs.DurationFromProto(msg.%[2]s.GetMaxQueryTime())
o := structs.QueryOptions{
MaxQueryTime: maxTime,
MinQueryIndex: msg.%[2]s.GetMinQueryIndex(),
}
return o.BlockingTimeout(maxQueryTime, defaultQueryTime)
}
// HasTimedOut implements structs.RPCInfo // HasTimedOut implements structs.RPCInfo
func (msg *%[1]s) HasTimedOut(start time.Time, rpcHoldTimeout time.Duration, a time.Duration, b time.Duration) (bool, error) { func (msg *%[1]s) HasTimedOut(start time.Time, rpcHoldTimeout time.Duration, a time.Duration, b time.Duration) (bool, error) {
if msg == nil || msg.%[2]s == nil { if msg == nil || msg.%[2]s == nil {