mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-31 14:54:27 +00:00
Graduate PortForwardWebsockets to Beta
Kubernetes-commit: 3ae3b4ea551443d8ef695d31bf0c51963fe35ac3
This commit is contained in:
parent
cea15394b3
commit
6e4469285c
@ -21,21 +21,21 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ httpstream.Dialer = &fallbackDialer{}
|
var _ httpstream.Dialer = &FallbackDialer{}
|
||||||
|
|
||||||
// fallbackDialer encapsulates a primary and secondary dialer, including
|
// FallbackDialer encapsulates a primary and secondary dialer, including
|
||||||
// the boolean function to determine if the primary dialer failed. Implements
|
// the boolean function to determine if the primary dialer failed. Implements
|
||||||
// the httpstream.Dialer interface.
|
// the httpstream.Dialer interface.
|
||||||
type fallbackDialer struct {
|
type FallbackDialer struct {
|
||||||
primary httpstream.Dialer
|
primary httpstream.Dialer
|
||||||
secondary httpstream.Dialer
|
secondary httpstream.Dialer
|
||||||
shouldFallback func(error) bool
|
shouldFallback func(error) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFallbackDialer creates the fallbackDialer with the primary and secondary dialers,
|
// NewFallbackDialer creates the FallbackDialer with the primary and secondary dialers,
|
||||||
// as well as the boolean function to determine if the primary dialer failed.
|
// as well as the boolean function to determine if the primary dialer failed.
|
||||||
func NewFallbackDialer(primary, secondary httpstream.Dialer, shouldFallback func(error) bool) httpstream.Dialer {
|
func NewFallbackDialer(primary, secondary httpstream.Dialer, shouldFallback func(error) bool) httpstream.Dialer {
|
||||||
return &fallbackDialer{
|
return &FallbackDialer{
|
||||||
primary: primary,
|
primary: primary,
|
||||||
secondary: secondary,
|
secondary: secondary,
|
||||||
shouldFallback: shouldFallback,
|
shouldFallback: shouldFallback,
|
||||||
@ -47,7 +47,7 @@ func NewFallbackDialer(primary, secondary httpstream.Dialer, shouldFallback func
|
|||||||
// httstream.Connection and the negotiated protocol version accepted. If the initial
|
// httstream.Connection and the negotiated protocol version accepted. If the initial
|
||||||
// primary dialer fails, this function attempts the secondary dialer. Returns an error
|
// primary dialer fails, this function attempts the secondary dialer. Returns an error
|
||||||
// if one occurs.
|
// if one occurs.
|
||||||
func (f *fallbackDialer) Dial(protocols ...string) (httpstream.Connection, string, error) {
|
func (f *FallbackDialer) Dial(protocols ...string) (httpstream.Connection, string, error) {
|
||||||
conn, version, err := f.primary.Dial(protocols...)
|
conn, version, err := f.primary.Dial(protocols...)
|
||||||
if err != nil && f.shouldFallback(err) {
|
if err != nil && f.shouldFallback(err) {
|
||||||
klog.V(4).Infof("fallback to secondary dialer from primary dialer err: %v", err)
|
klog.V(4).Infof("fallback to secondary dialer from primary dialer err: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user