-
Notifications
You must be signed in to change notification settings - Fork 6
/
cluster.go
51 lines (47 loc) · 1.33 KB
/
cluster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
core "github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
endpoint "github.com/envoyproxy/go-control-plane/envoy/api/v2/endpoint"
"github.com/envoyproxy/go-control-plane/pkg/cache"
"github.com/golang/protobuf/ptypes"
"log"
"time"
)
func BuildCluster() []cache.Resource {
var clusterName1 = "service_bbc"
log.Println(">>>>>>>>>>>>>>>>>>> creating cluster ", clusterName1)
h := &core.Address{Address: &core.Address_SocketAddress{
SocketAddress: &core.SocketAddress{
Address: "127.0.0.1",
Protocol: core.SocketAddress_TCP,
PortSpecifier: &core.SocketAddress_PortValue{
PortValue: uint32(8080),
},
},
}}
return []cache.Resource{
&v2.Cluster{
Name: clusterName1,
ConnectTimeout: ptypes.DurationProto(2 * time.Second),
ClusterDiscoveryType: &v2.Cluster_Type{Type: v2.Cluster_STRICT_DNS},
LbPolicy: v2.Cluster_ROUND_ROBIN,
LoadAssignment: &v2.ClusterLoadAssignment{
ClusterName: clusterName1,
Endpoints: []*endpoint.LocalityLbEndpoints{
{
LbEndpoints: []*endpoint.LbEndpoint{
{
HostIdentifier: &endpoint.LbEndpoint_Endpoint{
Endpoint: &endpoint.Endpoint{
Address: h,
},
},
},
},
},
},
},
},
}
}