mirror of https://github.com/grpc/grpc-go.git
				
				
				
			xds: move balancer/resolver registation to package xds (#3640)
This commit is contained in:
		
							parent
							
								
									e786c2dfb2
								
							
						
					
					
						commit
						30c53e745c
					
				| 
						 | 
				
			
			@ -9,13 +9,11 @@ hello world
 | 
			
		|||
example](https://github.com/grpc/grpc-go/tree/master/examples/helloworld). The
 | 
			
		||||
server replies with responses including its hostname.
 | 
			
		||||
 | 
			
		||||
**Note** that xDS support is incomplete and experimental, with limited
 | 
			
		||||
compatibility.
 | 
			
		||||
 | 
			
		||||
## xDS environment setup
 | 
			
		||||
 | 
			
		||||
This example doesn't include instuctions to setup xDS environment. Please
 | 
			
		||||
refer to documentation specific for your xDS management server.
 | 
			
		||||
This example doesn't include instructions to setup xDS environment. Please refer
 | 
			
		||||
to documentation specific for your xDS management server. Examples will be added
 | 
			
		||||
later.
 | 
			
		||||
 | 
			
		||||
The client also needs a bootstrap file. See [gRFC
 | 
			
		||||
A27](https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md#xdsclient-and-bootstrap-file)
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +24,7 @@ for the bootstrap format.
 | 
			
		|||
The client application needs to import the xDS package to install the resolver and balancers:
 | 
			
		||||
 | 
			
		||||
```go
 | 
			
		||||
_ "google.golang.org/grpc/xds/experimental" // To install the xds resolvers and balancers.
 | 
			
		||||
_ "google.golang.org/grpc/xds" // To install the xds resolvers and balancers.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Then, use `xds` target scheme for the ClientConn.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,7 @@ import (
 | 
			
		|||
	"google.golang.org/grpc"
 | 
			
		||||
	pb "google.golang.org/grpc/examples/helloworld/helloworld"
 | 
			
		||||
 | 
			
		||||
	// TODO: change this to xds after the xds package is released.
 | 
			
		||||
	_ "google.golang.org/grpc/xds/experimental" // To install the xds resolvers and balancers.
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ import (
 | 
			
		|||
	"google.golang.org/grpc/grpclog"
 | 
			
		||||
	testpb "google.golang.org/grpc/interop/grpc_testing"
 | 
			
		||||
	"google.golang.org/grpc/peer"
 | 
			
		||||
	_ "google.golang.org/grpc/xds/experimental"
 | 
			
		||||
	_ "google.golang.org/grpc/xds"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type statsWatcherKey struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,13 +16,14 @@
 | 
			
		|||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Package experimental contains xds implementation, still in experimental
 | 
			
		||||
// state. Users only need to import this package to get all xds functionality.
 | 
			
		||||
// Things are expected to change fast until we get to a stable state, at
 | 
			
		||||
// which point, all this will be moved to the xds package.
 | 
			
		||||
// Package experimental contains xds implementation. Users only need to import
 | 
			
		||||
// this package to get all xds functionality.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: import package xds instead.
 | 
			
		||||
package experimental
 | 
			
		||||
 | 
			
		||||
// TODO: remove this package after one release.
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	_ "google.golang.org/grpc/xds/internal/balancer" // Register the balancers.
 | 
			
		||||
	_ "google.golang.org/grpc/xds/internal/resolver" // Register the xds_resolver
 | 
			
		||||
	_ "google.golang.org/grpc/xds" // Register the balancers and resolvers.
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
/*
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright 2020 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 xds contains xds implementation. Users need to import this package to
 | 
			
		||||
// get all xds functionality.
 | 
			
		||||
//
 | 
			
		||||
// See https://github.com/grpc/grpc-go/tree/master/examples/features/xds for
 | 
			
		||||
// example.
 | 
			
		||||
package xds
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	_ "google.golang.org/grpc/xds/internal/balancer" // Register the balancers.
 | 
			
		||||
	_ "google.golang.org/grpc/xds/internal/resolver" // Register the xds_resolver
 | 
			
		||||
)
 | 
			
		||||
		Loading…
	
		Reference in New Issue