Remove single-entry var blocks (#1589)

This commit is contained in:
田欧
2017-10-18 11:59:23 -05:00
committed by dfawley
parent 16c41925b8
commit faebfcb7bf
13 changed files with 49 additions and 80 deletions

View File

@ -25,14 +25,12 @@ import (
// DefaultBackoffConfig uses values specified for backoff in // DefaultBackoffConfig uses values specified for backoff in
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. // https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
var ( var DefaultBackoffConfig = BackoffConfig{
DefaultBackoffConfig = BackoffConfig{
MaxDelay: 120 * time.Second, MaxDelay: 120 * time.Second,
baseDelay: 1.0 * time.Second, baseDelay: 1.0 * time.Second,
factor: 1.6, factor: 1.6,
jitter: 0.2, jitter: 0.2,
} }
)
// backoffStrategy defines the methodology for backing off after a grpc // backoffStrategy defines the methodology for backing off after a grpc
// connection failure. // connection failure.

View File

@ -30,9 +30,7 @@ import (
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
) )
var ( var duration = flag.Int("duration", math.MaxInt32, "The duration in seconds to run the benchmark server")
duration = flag.Int("duration", math.MaxInt32, "The duration in seconds to run the benchmark server")
)
func main() { func main() {
flag.Parse() flag.Parse()

View File

@ -37,9 +37,7 @@ import (
"google.golang.org/grpc/testdata" "google.golang.org/grpc/testdata"
) )
var ( var caFile = flag.String("ca_file", "", "The file containing the CA root cert file")
caFile = flag.String("ca_file", "", "The file containing the CA root cert file")
)
type lockingHistogram struct { type lockingHistogram struct {
mu sync.Mutex mu sync.Mutex

View File

@ -92,8 +92,7 @@ func (protoCodec) String() string {
return "proto" return "proto"
} }
var ( var protoBufferPool = &sync.Pool{
protoBufferPool = &sync.Pool{
New: func() interface{} { New: func() interface{} {
return &cachedProtoBuffer{ return &cachedProtoBuffer{
Buffer: proto.Buffer{}, Buffer: proto.Buffer{},
@ -101,4 +100,3 @@ var (
} }
}, },
} }
)

View File

@ -34,10 +34,8 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
) )
var (
// alpnProtoStr are the specified application level protocols for gRPC. // alpnProtoStr are the specified application level protocols for gRPC.
alpnProtoStr = []string{"h2"} var alpnProtoStr = []string{"h2"}
)
// PerRPCCredentials defines the common interface for the credentials which need to // PerRPCCredentials defines the common interface for the credentials which need to
// attach security information to every RPC (e.g., oauth2). // attach security information to every RPC (e.g., oauth2).
@ -74,11 +72,9 @@ type AuthInfo interface {
AuthType() string AuthType() string
} }
var (
// ErrConnDispatched indicates that rawConn has been dispatched out of gRPC // ErrConnDispatched indicates that rawConn has been dispatched out of gRPC
// and the caller should not close rawConn. // and the caller should not close rawConn.
ErrConnDispatched = errors.New("credentials: rawConn is dispatched out of gRPC") var ErrConnDispatched = errors.New("credentials: rawConn is dispatched out of gRPC")
)
// TransportCredentials defines the common interface for all the live gRPC wire // TransportCredentials defines the common interface for all the live gRPC wire
// protocols and supported transport security protocols (e.g., TLS, SSL). // protocols and supported transport security protocols (e.g., TLS, SSL).

View File

@ -29,12 +29,10 @@ import (
rgpb "google.golang.org/grpc/examples/route_guide/routeguide" rgpb "google.golang.org/grpc/examples/route_guide/routeguide"
) )
var ( var msg = &rgpb.RouteNote{
msg = &rgpb.RouteNote{
Location: &rgpb.Point{Latitude: 17, Longitude: 29}, Location: &rgpb.Point{Latitude: 17, Longitude: 29},
Message: "Taxi-cab", Message: "Taxi-cab",
} }
)
func TestRouteChat(t *testing.T) { func TestRouteChat(t *testing.T) {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)

View File

@ -394,12 +394,10 @@ func DoPerRPCCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScop
} }
} }
var ( var testMetadata = metadata.MD{
testMetadata = metadata.MD{
"key1": []string{"value1"}, "key1": []string{"value1"},
"key2": []string{"value2"}, "key2": []string{"value2"},
} }
)
// DoCancelAfterBegin cancels the RPC after metadata has been sent but before payloads are sent. // DoCancelAfterBegin cancels the RPC after metadata has been sent but before payloads are sent.
func DoCancelAfterBegin(tc testpb.TestServiceClient, args ...grpc.CallOption) { func DoCancelAfterBegin(tc testpb.TestServiceClient, args ...grpc.CallOption) {

View File

@ -50,9 +50,7 @@ const (
txtAttribute = "grpc_config=" txtAttribute = "grpc_config="
) )
var ( var errMissingAddr = errors.New("missing address")
errMissingAddr = errors.New("missing address")
)
// NewBuilder creates a dnsBuilder which is used to factory DNS resolvers. // NewBuilder creates a dnsBuilder which is used to factory DNS resolvers.
func NewBuilder() resolver.Builder { func NewBuilder() resolver.Builder {

View File

@ -150,8 +150,7 @@ func div(b []byte) []string {
// resolver functionality, with scfs as the input and scs used for validation of // resolver functionality, with scfs as the input and scs used for validation of
// the output. For scfs[3], it corresponds to empty service config, since there // the output. For scfs[3], it corresponds to empty service config, since there
// isn't a matched choice. // isn't a matched choice.
var ( var scfs = []string{
scfs = []string{
`[ `[
{ {
"clientLanguage": [ "clientLanguage": [
@ -490,11 +489,9 @@ var (
} }
]`, ]`,
} }
)
// scs contains an array of service config string in JSON format. // scs contains an array of service config string in JSON format.
var ( var scs = []string{
scs = []string{
`{ `{
"methodConfig": [ "methodConfig": [
{ {
@ -547,7 +544,6 @@ var (
] ]
}`, }`,
} }
)
// scLookupTbl is a set, which contains targets that have service config. Target // scLookupTbl is a set, which contains targets that have service config. Target
// not in this set should not have service config. // not in this set should not have service config.

View File

@ -27,9 +27,7 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
) )
var ( var errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: missing ']' in address [2001:db8:a0b:12f0::1:443")
errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: missing ']' in address [2001:db8:a0b:12f0::1:443")
)
func replaceNetFunc() func() { func replaceNetFunc() func() {
oldLookupHost := lookupHost oldLookupHost := lookupHost

View File

@ -26,9 +26,7 @@ import (
"net" "net"
) )
var ( var errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: address [2001:db8:a0b:12f0::1:443: missing ']' in address")
errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: address [2001:db8:a0b:12f0::1:443: missing ']' in address")
)
func replaceNetFunc() func() { func replaceNetFunc() func() {
oldLookupHost := lookupHost oldLookupHost := lookupHost

View File

@ -418,11 +418,9 @@ func (s *Server) GetServiceInfo() map[string]ServiceInfo {
return ret return ret
} }
var (
// ErrServerStopped indicates that the operation is now illegal because of // ErrServerStopped indicates that the operation is now illegal because of
// the server being stopped. // the server being stopped.
ErrServerStopped = errors.New("grpc: the server has been stopped") var ErrServerStopped = errors.New("grpc: the server has been stopped")
)
func (s *Server) useTransportAuthenticator(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (s *Server) useTransportAuthenticator(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
if s.opts.creds == nil { if s.opts.creds == nil {

View File

@ -41,12 +41,9 @@ const (
gamma = 2 gamma = 2
) )
var ( // Adding arbitrary data to ping so that its ack can be identified.
// Adding arbitrary data to ping so that its ack can be
// identified.
// Easter-egg: what does the ping message say? // Easter-egg: what does the ping message say?
bdpPing = &ping{data: [8]byte{2, 4, 16, 16, 9, 14, 7, 7}} var bdpPing = &ping{data: [8]byte{2, 4, 16, 16, 9, 14, 7, 7}}
)
type bdpEstimator struct { type bdpEstimator struct {
// sentAt is the time when the ping was sent. // sentAt is the time when the ping was sent.