mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
5
vendor/google.golang.org/grpc/naming/dns_resolver.go
generated
vendored
5
vendor/google.golang.org/grpc/naming/dns_resolver.go
generated
vendored
@ -19,13 +19,13 @@
|
||||
package naming
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
|
||||
@ -37,6 +37,9 @@ const (
|
||||
var (
|
||||
errMissingAddr = errors.New("missing address")
|
||||
errWatcherClose = errors.New("watcher has been closed")
|
||||
|
||||
lookupHost = net.DefaultResolver.LookupHost
|
||||
lookupSRV = net.DefaultResolver.LookupSRV
|
||||
)
|
||||
|
||||
// NewDNSResolverWithFreq creates a DNS Resolver that can resolve DNS names, and
|
||||
|
16
vendor/google.golang.org/grpc/naming/dns_resolver_test.go
generated
vendored
16
vendor/google.golang.org/grpc/naming/dns_resolver_test.go
generated
vendored
@ -19,6 +19,7 @@
|
||||
package naming
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
@ -253,6 +254,21 @@ func testResolver(t *testing.T, freq time.Duration, slp time.Duration) {
|
||||
}
|
||||
}
|
||||
|
||||
func replaceNetFunc() func() {
|
||||
oldLookupHost := lookupHost
|
||||
oldLookupSRV := lookupSRV
|
||||
lookupHost = func(ctx context.Context, host string) ([]string, error) {
|
||||
return hostLookup(host)
|
||||
}
|
||||
lookupSRV = func(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) {
|
||||
return srvLookup(service, proto, name)
|
||||
}
|
||||
return func() {
|
||||
lookupHost = oldLookupHost
|
||||
lookupSRV = oldLookupSRV
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolve(t *testing.T) {
|
||||
defer replaceNetFunc()()
|
||||
testResolver(t, time.Millisecond*5, time.Millisecond*10)
|
||||
|
34
vendor/google.golang.org/grpc/naming/go17.go
generated
vendored
34
vendor/google.golang.org/grpc/naming/go17.go
generated
vendored
@ -1,34 +0,0 @@
|
||||
// +build go1.6,!go1.8
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package naming
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
lookupHost = func(ctx context.Context, host string) ([]string, error) { return net.LookupHost(host) }
|
||||
lookupSRV = func(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) {
|
||||
return net.LookupSRV(service, proto, name)
|
||||
}
|
||||
)
|
42
vendor/google.golang.org/grpc/naming/go17_test.go
generated
vendored
42
vendor/google.golang.org/grpc/naming/go17_test.go
generated
vendored
@ -1,42 +0,0 @@
|
||||
// +build go1.6, !go1.8
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package naming
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func replaceNetFunc() func() {
|
||||
oldLookupHost := lookupHost
|
||||
oldLookupSRV := lookupSRV
|
||||
lookupHost = func(ctx context.Context, host string) ([]string, error) {
|
||||
return hostLookup(host)
|
||||
}
|
||||
lookupSRV = func(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) {
|
||||
return srvLookup(service, proto, name)
|
||||
}
|
||||
return func() {
|
||||
lookupHost = oldLookupHost
|
||||
lookupSRV = oldLookupSRV
|
||||
}
|
||||
}
|
28
vendor/google.golang.org/grpc/naming/go18.go
generated
vendored
28
vendor/google.golang.org/grpc/naming/go18.go
generated
vendored
@ -1,28 +0,0 @@
|
||||
// +build go1.8
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package naming
|
||||
|
||||
import "net"
|
||||
|
||||
var (
|
||||
lookupHost = net.DefaultResolver.LookupHost
|
||||
lookupSRV = net.DefaultResolver.LookupSRV
|
||||
)
|
41
vendor/google.golang.org/grpc/naming/go18_test.go
generated
vendored
41
vendor/google.golang.org/grpc/naming/go18_test.go
generated
vendored
@ -1,41 +0,0 @@
|
||||
// +build go1.8
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2017 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package naming
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
)
|
||||
|
||||
func replaceNetFunc() func() {
|
||||
oldLookupHost := lookupHost
|
||||
oldLookupSRV := lookupSRV
|
||||
lookupHost = func(ctx context.Context, host string) ([]string, error) {
|
||||
return hostLookup(host)
|
||||
}
|
||||
lookupSRV = func(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) {
|
||||
return srvLookup(service, proto, name)
|
||||
}
|
||||
return func() {
|
||||
lookupHost = oldLookupHost
|
||||
lookupSRV = oldLookupSRV
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user