fix(archied): the watchdog heartbeat proves liveness and a stalled run loop reports degraded readiness (#1840)
State Store calls the daemon makes without a deadline now get one.
This commit is contained in:
6 files changed
+68
-59
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package staterpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -93,3 +94,16 @@ func ServerKeepalivePolicy() keepalive.EnforcementPolicy {
|
||||
// instead of failing while it is down or restarting. A call that must not
|
||||
// wait carries its own deadline.
|
||||
var WaitForPeer = grpc.WithDefaultCallOptions(grpc.WaitForReady(true))
|
||||
|
||||
// WithCallDeadline bounds every unary call that carries no deadline of its
|
||||
// own, so a slow State Store fails the call instead of parking its caller.
|
||||
func WithCallDeadline(d time.Duration) grpc.DialOption {
|
||||
return grpc.WithChainUnaryInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
if _, ok := ctx.Deadline(); !ok {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, d)
|
||||
defer cancel()
|
||||
}
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user