Skip to content

Commit

Permalink
feat: add ContextKeyDialFunc (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr authored Jun 24, 2024
1 parent e452ae2 commit 567ceb9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const (
EnvAuthToken = "KETO_BEARER_TOKEN" //nolint:gosec // just the key, not the value
EnvAuthority = "KETO_AUTHORITY"

ContextKeyTimeout contextKeys = "timeout"
ContextKeyTimeout contextKeys = "timeout"
ContextKeyDialFunc contextKeys = "dial"
)

type connectionDetails struct {
Expand Down Expand Up @@ -137,6 +138,10 @@ func Conn(ctx context.Context, remote string, details connectionDetails) (*grpc.
defer cancel()
}

if dial, ok := ctx.Value(ContextKeyDialFunc).(func(context.Context, string) (*grpc.ClientConn, error)); ok {
return dial(ctx, remote)
}

return grpc.DialContext(
ctx,
remote,
Expand Down

0 comments on commit 567ceb9

Please sign in to comment.