@@ -61,6 +61,8 @@ const (
61
61
minRPCTimeout = 1 * time .Second
62
62
//maxRPCTimeout is maximum rpc call timeout allowed
63
63
maxRPCTimeout = 5 * time .Second
64
+ // maxQueryRPCTimeout is the maximum rpc call timeout allowed for query
65
+ maxQueryRPCTimeout = 20 * time .Second
64
66
)
65
67
66
68
var (
@@ -99,8 +101,17 @@ func chanTimeout(timeout time.Duration) func(builder *contextBuilder) {
99
101
}
100
102
}
101
103
104
+ // newChannelContext - Get a rpc channel context for query
105
+ func newChannelContextForQuery (ctx context.Context , options ... func (builder * contextBuilder )) (context.Context , context.CancelFunc , []yarpc.CallOption ) {
106
+ return newChannelContextHelper (ctx , true , options ... )
107
+ }
108
+
102
109
// newChannelContext - Get a rpc channel context
103
110
func newChannelContext (ctx context.Context , options ... func (builder * contextBuilder )) (context.Context , context.CancelFunc , []yarpc.CallOption ) {
111
+ return newChannelContextHelper (ctx , false , options ... )
112
+ }
113
+
114
+ func newChannelContextHelper (ctx context.Context , isQuery bool , options ... func (builder * contextBuilder )) (context.Context , context.CancelFunc , []yarpc.CallOption ) {
104
115
rpcTimeout := defaultRPCTimeout
105
116
if ctx != nil {
106
117
// Set rpc timeout less than context timeout to allow for retries when call gets lost
@@ -110,8 +121,10 @@ func newChannelContext(ctx context.Context, options ...func(builder *contextBuil
110
121
// Make sure to not set rpc timeout lower than minRPCTimeout
111
122
if rpcTimeout < minRPCTimeout {
112
123
rpcTimeout = minRPCTimeout
113
- } else if rpcTimeout > maxRPCTimeout {
124
+ } else if rpcTimeout > maxRPCTimeout && ! isQuery {
114
125
rpcTimeout = maxRPCTimeout
126
+ } else if rpcTimeout > maxQueryRPCTimeout && isQuery {
127
+ rpcTimeout = maxQueryRPCTimeout
115
128
}
116
129
}
117
130
}
0 commit comments