Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust timeouts in dialers #285

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions oracle/pkg/agents/common/dbdaemonlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
)

var (
// CallTimeout can be set via a flag by the program importing the library.
CallTimeout = 15 * time.Minute
// failsafe for callers who have not specified a real ctx.
callTimeout = 15 * time.Minute
callTimeoutNetwork = 1 * time.Minute
)

// withTimeout returns a context with a default timeout if the input context has no timeout.
Expand All @@ -38,15 +39,15 @@ func withTimeout(ctx context.Context, timeOut time.Duration) (context.Context, c

// DatabaseDaemonDialLocalhost connects to a local Database Daemon via gRPC.
func DatabaseDaemonDialLocalhost(ctx context.Context, port int, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
ctxDial, cancel := withTimeout(ctx, CallTimeout)
ctxDial, cancel := withTimeout(ctx, callTimeout)
defer cancel()
finalOpts := append([]grpc.DialOption{grpc.WithTransportCredentials(local.NewCredentials())}, opts...)
return grpc.DialContext(ctxDial, fmt.Sprintf("localhost:%d", port), finalOpts...)
}

// DatabaseDaemonDialSocket connects to Database Daemon via gRPC.
func DatabaseDaemonDialSocket(ctx context.Context, socket string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
ctxDial, cancel := withTimeout(ctx, CallTimeout)
ctxDial, cancel := withTimeout(ctx, callTimeout)
defer cancel()
endpoint := fmt.Sprintf("passthrough://unix/%s", socket)
finalOpts := append([]grpc.DialOption{grpc.WithTransportCredentials(local.NewCredentials()), grpc.WithContextDialer(GrpcUnixDialer)}, opts...)
Expand All @@ -55,7 +56,7 @@ func DatabaseDaemonDialSocket(ctx context.Context, socket string, opts ...grpc.D

// DatabaseDaemonDialService connects to Database Service via gRPC.
func DatabaseDaemonDialService(ctx context.Context, serviceAndPort string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
ctxDial, cancel := withTimeout(ctx, CallTimeout)
ctxDial, cancel := withTimeout(ctx, callTimeoutNetwork)
defer cancel()
finalOpts := append([]grpc.DialOption{grpc.WithInsecure()}, opts...)
return grpc.DialContext(ctxDial, serviceAndPort, finalOpts...)
Expand Down