throttler: Various fixes in the comments.

This commit is contained in:
Michael Berlin 2016-06-08 16:54:23 -07:00
Родитель c540714d99
Коммит f8de8e0706
6 изменённых файлов: 18 добавлений и 16 удалений

Просмотреть файл

@ -44,8 +44,8 @@ func factory(addr string) (throttlerclient.Client, error) {
return &client{conn, gRPCClient}, nil
}
// MaxRates is part of the ThrottlerClient interface and returns the current
// max rate for each throttler of the process.
// MaxRates is part of the throttlerclient.Client interface and returns the
// current max rate for each throttler of the process.
func (c *client) MaxRates(ctx context.Context) (map[string]int64, error) {
response, err := c.gRPCClient.MaxRates(ctx, &throttlerdata.MaxRatesRequest{})
if err != nil {
@ -54,8 +54,8 @@ func (c *client) MaxRates(ctx context.Context) (map[string]int64, error) {
return response.Rates, nil
}
// SetMaxRate is part of the ThrottlerClient interface and sets the rate on all
// throttlers of the server.
// SetMaxRate is part of the throttlerclient.Client interface and sets the rate
// on all throttlers of the server.
func (c *client) SetMaxRate(ctx context.Context, rate int64) ([]string, error) {
request := &throttlerdata.SetMaxRateRequest{
Rate: rate,
@ -68,7 +68,7 @@ func (c *client) SetMaxRate(ctx context.Context, rate int64) ([]string, error) {
return response.Names, nil
}
// Close is part of the ThrottlerClient interface.
// Close is part of the throttlerclient.Client interface.
func (c *client) Close() {
c.conn.Close()
}

Просмотреть файл

@ -15,7 +15,8 @@ import (
"google.golang.org/grpc"
)
// Test gRPC interface using a throttler client and server.
// TestThrottlerServer tests the gRPC implementation using a throttler client
// and server.
func TestThrottlerServer(t *testing.T) {
s, port := startGRPCServer(t)
// Use the global manager which is a singleton.
@ -31,7 +32,8 @@ func TestThrottlerServer(t *testing.T) {
throttlerclienttest.TestSuite(t, client)
}
// Test panic handling in the throttler server.
// TestThrottlerServerPanics tests the panic handling of the gRPC throttler
// server implementation.
func TestThrottlerServerPanics(t *testing.T) {
s, port := startGRPCServer(t)
// For testing the panic handling, use a fake Manager instead.

Просмотреть файл

@ -27,9 +27,9 @@ func NewServer(m throttler.Manager) *Server {
return &Server{m}
}
// MaxRates implements the gRPC server interface. returns the current max
// MaxRates implements the gRPC server interface. It returns the current max
// rate for each throttler of the process.
func (s *Server) MaxRates(ctx context.Context, request *throttlerdata.MaxRatesRequest) (_ *throttlerdata.MaxRatesResponse, err error) {
func (s *Server) MaxRates(_ context.Context, request *throttlerdata.MaxRatesRequest) (_ *throttlerdata.MaxRatesResponse, err error) {
defer servenv.HandlePanic("throttler", &err)
rates := s.manager.MaxRates()
@ -40,7 +40,7 @@ func (s *Server) MaxRates(ctx context.Context, request *throttlerdata.MaxRatesRe
// SetMaxRate implements the gRPC server interface. It sets the rate on all
// throttlers controlled by the manager.
func (s *Server) SetMaxRate(ctx context.Context, request *throttlerdata.SetMaxRateRequest) (_ *throttlerdata.SetMaxRateResponse, err error) {
func (s *Server) SetMaxRate(_ context.Context, request *throttlerdata.SetMaxRateRequest) (_ *throttlerdata.SetMaxRateResponse, err error) {
defer servenv.HandlePanic("throttler", &err)
names := s.manager.SetMaxRate(request.Rate)

Просмотреть файл

@ -23,5 +23,5 @@ message SetMaxRateRequest {
// SetMaxRateResponse is returned by the SetMaxRate RPC.
message SetMaxRateResponse {
// names is the list of throttler names which were updated.
repeated string names = 1;
repeated string names = 1;
}

Просмотреть файл

@ -1,6 +1,6 @@
// RPC interface for the internal resharding throttler (go/vt/throttler) which
// is used by the resharding clone process (vtworker) and filtered replication
// (vttablet).
// gRPC RPC interface for the internal resharding throttler (go/vt/throttler)
// which is used by the resharding clone process (vtworker) and filtered
// replication (vttablet).
syntax = "proto3";

Просмотреть файл

@ -54,13 +54,13 @@ class GRpcProtocolsFlavor(protocols_flavor.ProtocolsFlavor):
def service_map(self):
return [
'grpc-tabletmanager',
'grpc-throttler',
'grpc-queryservice',
'grpc-updatestream',
'grpc-vtctl',
'grpc-vtworker',
'grpc-tabletmanager',
'grpc-vtgateservice',
'grpc-throttler',
]
def vttest_protocol(self):