From 00334dae600f95f01529ecdc25c63c8df1c0d138 Mon Sep 17 00:00:00 2001 From: Menghan Li Date: Wed, 13 Feb 2019 14:57:23 -0800 Subject: [PATCH] comments --- internal/balancerload/load.go | 17 ++++++++++------- internal/balancerload/orca/orca.go | 2 +- internal/balancerload/orca/orca_test.go | 2 -- stream.go | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/balancerload/load.go b/internal/balancerload/load.go index fb733b3214be..3a905d96657e 100644 --- a/internal/balancerload/load.go +++ b/internal/balancerload/load.go @@ -14,28 +14,31 @@ * limitations under the License. */ +// Package balancerload defines APIs to parse server loads in trailers. The +// parsed loads are sent to balancers in DoneInfo. package balancerload import ( "google.golang.org/grpc/metadata" ) -// ServerLoadParser converts loads from metadata into a concrete type. -type ServerLoadParser interface { +// Parser converts loads from metadata into a concrete type. +type Parser interface { + // Parse parses loads from metadata. Parse(md metadata.MD) interface{} } -var parser ServerLoadParser +var parser Parser -// SetServerLoadReader sets the load parser. +// SetParser sets the load parser. // // Not mutex-protected, should be called before any gRPC functions. -func SetServerLoadReader(lr ServerLoadParser) { +func SetParser(lr Parser) { parser = lr } -// ParseServerLoad calls parser.Read(). -func ParseServerLoad(md metadata.MD) interface{} { +// Parse calls parser.Read(). +func Parse(md metadata.MD) interface{} { if parser == nil { return nil } diff --git a/internal/balancerload/orca/orca.go b/internal/balancerload/orca/orca.go index 554d3d472f1b..8b8a1f17860a 100644 --- a/internal/balancerload/orca/orca.go +++ b/internal/balancerload/orca/orca.go @@ -80,5 +80,5 @@ func (*loadParser) Parse(md metadata.MD) interface{} { } func init() { - balancerload.SetServerLoadReader(&loadParser{}) + balancerload.SetParser(&loadParser{}) } diff --git a/internal/balancerload/orca/orca_test.go b/internal/balancerload/orca/orca_test.go index ac2b021fe8ea..10a16085b84e 100644 --- a/internal/balancerload/orca/orca_test.go +++ b/internal/balancerload/orca/orca_test.go @@ -14,8 +14,6 @@ * limitations under the License. */ -//go:generate protoc -I ./orca_v1 --go_out=plugins=grpc:./orca_v1 ./orca_v1/orca.proto - package orca import ( diff --git a/stream.go b/stream.go index b4389a7cda9d..639f5278f4e5 100644 --- a/stream.go +++ b/stream.go @@ -932,7 +932,7 @@ func (a *csAttempt) finish(err error) { Trailer: tr, BytesSent: a.s != nil, BytesReceived: br, - ServerLoad: balancerload.ParseServerLoad(tr), + ServerLoad: balancerload.Parse(tr), }) } if a.statsHandler != nil {