Skip to content

Commit

Permalink
Update examples/dyplomat to v3 (#620)
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Gutierrez Segales <rsegales@nvidia.com>
Co-authored-by: Raul Gutierrez Segales <rsegales@nvidia.com>
  • Loading branch information
rgs1 and rgs1 committed Jan 27, 2023
1 parent 29a4b73 commit 65d53e6
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions examples/dyplomat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import (

"google.golang.org/grpc"

api "github.com/envoyproxy/go-control-plane/envoy/api/v2"
discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v2"
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
endpointv3 "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
clusterservice "github.com/envoyproxy/go-control-plane/envoy/service/cluster/v3"
discoverygrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
endpointservice "github.com/envoyproxy/go-control-plane/envoy/service/endpoint/v3"
listenerservice "github.com/envoyproxy/go-control-plane/envoy/service/listener/v3"
routeservice "github.com/envoyproxy/go-control-plane/envoy/service/route/v3"
"github.com/envoyproxy/go-control-plane/pkg/cache/types"
"github.com/envoyproxy/go-control-plane/pkg/cache/v2"
xds "github.com/envoyproxy/go-control-plane/pkg/server/v2"

endpoint "github.com/envoyproxy/go-control-plane/envoy/api/v2"
core "github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
endpointv2 "github.com/envoyproxy/go-control-plane/envoy/api/v2/endpoint"
"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
xds "github.com/envoyproxy/go-control-plane/pkg/server/v3"

corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/informers"
Expand All @@ -43,11 +44,11 @@ func main() {
grpcServer := grpc.NewServer()
lis, _ := net.Listen("tcp", ":8080")

discovery.RegisterAggregatedDiscoveryServiceServer(grpcServer, server)
api.RegisterEndpointDiscoveryServiceServer(grpcServer, server)
api.RegisterClusterDiscoveryServiceServer(grpcServer, server)
api.RegisterRouteDiscoveryServiceServer(grpcServer, server)
api.RegisterListenerDiscoveryServiceServer(grpcServer, server)
discoverygrpc.RegisterAggregatedDiscoveryServiceServer(grpcServer, server)
endpointservice.RegisterEndpointDiscoveryServiceServer(grpcServer, server)
clusterservice.RegisterClusterDiscoveryServiceServer(grpcServer, server)
routeservice.RegisterRouteDiscoveryServiceServer(grpcServer, server)
listenerservice.RegisterListenerDiscoveryServiceServer(grpcServer, server)

clusters, _ := CreateBootstrapClients()

Expand Down Expand Up @@ -116,19 +117,19 @@ func HandleEndpointsUpdate(oldObj, newObj interface{}) {
version++
}

func MakeEndpointsForCluster(service *EnvoyCluster) *endpoint.ClusterLoadAssignment {
func MakeEndpointsForCluster(service *EnvoyCluster) *endpointv3.ClusterLoadAssignment {
fmt.Printf("Updating endpoints for cluster %s: %v\n", service.name, service.endpoints)
cla := &endpoint.ClusterLoadAssignment{
cla := &endpointv3.ClusterLoadAssignment{
ClusterName: service.name,
Endpoints: []*endpointv2.LocalityLbEndpoints{},
Endpoints: []*endpointv3.LocalityLbEndpoints{},
}

for _, endpoint := range service.endpoints {
cla.Endpoints = append(cla.Endpoints,
&endpointv2.LocalityLbEndpoints{
LbEndpoints: []*endpointv2.LbEndpoint{{
HostIdentifier: &endpointv2.LbEndpoint_Endpoint{
Endpoint: &endpointv2.Endpoint{
&endpointv3.LocalityLbEndpoints{
LbEndpoints: []*endpointv3.LbEndpoint{{
HostIdentifier: &endpointv3.LbEndpoint_Endpoint{
Endpoint: &endpointv3.Endpoint{
Address: &core.Address{
Address: &core.Address_SocketAddress{
SocketAddress: &core.SocketAddress{
Expand Down

0 comments on commit 65d53e6

Please sign in to comment.