@@ -61,6 +61,8 @@ const (
6161 minRPCTimeout = 1 * time .Second
6262 //maxRPCTimeout is maximum rpc call timeout allowed
6363 maxRPCTimeout = 5 * time .Second
64+ // maxQueryRPCTimeout is the maximum rpc call timeout allowed for query
65+ maxQueryRPCTimeout = 20 * time .Second
6466)
6567
6668var (
@@ -99,8 +101,17 @@ func chanTimeout(timeout time.Duration) func(builder *contextBuilder) {
99101 }
100102}
101103
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+
102109// newChannelContext - Get a rpc channel context
103110func 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 ) {
104115 rpcTimeout := defaultRPCTimeout
105116 if ctx != nil {
106117 // 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
110121 // Make sure to not set rpc timeout lower than minRPCTimeout
111122 if rpcTimeout < minRPCTimeout {
112123 rpcTimeout = minRPCTimeout
113- } else if rpcTimeout > maxRPCTimeout {
124+ } else if rpcTimeout > maxRPCTimeout && ! isQuery {
114125 rpcTimeout = maxRPCTimeout
126+ } else if rpcTimeout > maxQueryRPCTimeout && isQuery {
127+ rpcTimeout = maxQueryRPCTimeout
115128 }
116129 }
117130 }
0 commit comments