Skip to content

Commit

Permalink
[lrs_stream_report] not rename import
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Oct 8, 2020
1 parent 985f6e5 commit 9870b33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions xds/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
"github.com/golang/protobuf/proto"
load2 "google.golang.org/grpc/xds/internal/client/load"
"google.golang.org/grpc/xds/internal/client/load"

"google.golang.org/grpc"
"google.golang.org/grpc/internal/backoff"
Expand Down Expand Up @@ -115,7 +115,7 @@ type APIClient interface {

// LoadReportingOptions contains configuration knobs for reporting load data.
type LoadReportingOptions struct {
load *load2.Store
loadStore *load.Store
}

// UpdateHandler receives and processes (by taking appropriate actions) xDS
Expand Down
19 changes: 9 additions & 10 deletions xds/internal/client/client_loadreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/xds/internal/client/load"
load2 "google.golang.org/grpc/xds/internal/client/load"
)

// NodeMetadataHostnameKey is the metadata key for specifying the target name in
Expand All @@ -33,10 +32,10 @@ const NodeMetadataHostnameKey = "PROXYLESS_CLIENT_HOSTNAME"
// - a ClientConn to this server (only if it's different from the xds server)
// - a load.Store that contains loads only for this server
type lrsClient struct {
refCount int
cancel func()
cc *grpc.ClientConn // nil if the server is same as the xds server
load *load2.Store
refCount int
cancel func()
cc *grpc.ClientConn // nil if the server is same as the xds server
loadStore *load.Store
}

// ReportLoad starts an load reporting stream to the given server. If the server
Expand All @@ -55,7 +54,7 @@ func (c *Client) ReportLoad(server string) (*load.Store, func()) {
// If there's already a client to this server, use it.
if c, ok := c.lrsClients[server]; ok {
c.refCount++
return c.load, c.cancel
return c.loadStore, c.cancel
}

// First reporting stream to this server.
Expand All @@ -82,13 +81,13 @@ func (c *Client) ReportLoad(server string) (*load.Store, func()) {
store := load.NewStore()
ctx, cancel := context.WithCancel(context.Background())
go c.apiClient.ReportLoad(ctx, c.cc, LoadReportingOptions{
load: store,
loadStore: store,
})

lrsC := &lrsClient{
refCount: 1,
cancel: cancel,
load: store,
refCount: 1,
cancel: cancel,
loadStore: store,
}
if newCC {
lrsC.cc = cc
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/client/transport_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/golang/protobuf/proto"
load2 "google.golang.org/grpc/xds/internal/client/load"
"google.golang.org/grpc/xds/internal/client/load"

"google.golang.org/grpc"
"google.golang.org/grpc/internal/buffer"
Expand Down Expand Up @@ -86,7 +86,7 @@ type VersionedClient interface {
// SendLoadStatsRequest will be invoked at regular intervals to send load
// report with load data reported since the last time this method was
// invoked.
SendLoadStatsRequest(s grpc.ClientStream, store *load2.Store, clusterNames []string) error
SendLoadStatsRequest(s grpc.ClientStream, store *load.Store, clusterNames []string) error
}

// TransportHelper contains all xDS transport protocol related functionality
Expand Down Expand Up @@ -484,11 +484,11 @@ func (t *TransportHelper) ReportLoad(ctx context.Context, cc *grpc.ClientConn, o
}

retries = 0
t.sendLoads(ctx, stream, opts.load, clusters, interval)
t.sendLoads(ctx, stream, opts.loadStore, clusters, interval)
}
}

func (t *TransportHelper) sendLoads(ctx context.Context, stream grpc.ClientStream, store *load2.Store, clusterNames []string, interval time.Duration) {
func (t *TransportHelper) sendLoads(ctx context.Context, stream grpc.ClientStream, store *load.Store, clusterNames []string, interval time.Duration) {
tick := time.NewTicker(interval)
defer tick.Stop()
for {
Expand Down

0 comments on commit 9870b33

Please sign in to comment.