Skip to content

Commit

Permalink
Fix "deprecated" function godoc comments to match standard formatting (
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc authored and dfawley committed May 2, 2018
1 parent e538e04 commit f8dbc38
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 96 deletions.
6 changes: 3 additions & 3 deletions benchmark/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func closeLoopUnary() {
close(ch)
wg.Wait()
conn.Close()
grpclog.Println(s.String())
grpclog.Infoln(s.String())

}

Expand Down Expand Up @@ -155,7 +155,7 @@ func closeLoopStream() {
close(ch)
wg.Wait()
conn.Close()
grpclog.Println(s.String())
grpclog.Infoln(s.String())
}

func main() {
Expand All @@ -166,7 +166,7 @@ func main() {
if err != nil {
grpclog.Fatalf("Failed to listen: %v", err)
}
grpclog.Println("Client profiling address: ", lis.Addr().String())
grpclog.Infoln("Client profiling address: ", lis.Addr().String())
if err := http.Serve(lis, nil); err != nil {
grpclog.Fatalf("Failed to serve: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions benchmark/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
if err != nil {
grpclog.Fatalf("Failed to listen: %v", err)
}
grpclog.Println("Server profiling address: ", lis.Addr().String())
grpclog.Infoln("Server profiling address: ", lis.Addr().String())
if err := http.Serve(lis, nil); err != nil {
grpclog.Fatalf("Failed to serve: %v", err)
}
Expand All @@ -50,7 +50,7 @@ func main() {
}
addr := lis.Addr().String()
stopper := benchmark.StartServer(benchmark.ServerInfo{Type: "protobuf", Listener: lis}) // listen on all interfaces
grpclog.Println("Server Address: ", addr)
grpclog.Infoln("Server Address: ", addr)
<-time.After(time.Duration(*duration) * time.Second)
stopper()
}
26 changes: 13 additions & 13 deletions benchmark/worker/benchmark_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@ func printClientConfig(config *testpb.ClientConfig) {
// will always create sync client
// - async client threads.
// - core list
grpclog.Printf(" * client type: %v (ignored, always creates sync client)", config.ClientType)
grpclog.Printf(" * async client threads: %v (ignored)", config.AsyncClientThreads)
grpclog.Infof(" * client type: %v (ignored, always creates sync client)", config.ClientType)
grpclog.Infof(" * async client threads: %v (ignored)", config.AsyncClientThreads)
// TODO: use cores specified by CoreList when setting list of cores is supported in go.
grpclog.Printf(" * core list: %v (ignored)", config.CoreList)

grpclog.Printf(" - security params: %v", config.SecurityParams)
grpclog.Printf(" - core limit: %v", config.CoreLimit)
grpclog.Printf(" - payload config: %v", config.PayloadConfig)
grpclog.Printf(" - rpcs per chann: %v", config.OutstandingRpcsPerChannel)
grpclog.Printf(" - channel number: %v", config.ClientChannels)
grpclog.Printf(" - load params: %v", config.LoadParams)
grpclog.Printf(" - rpc type: %v", config.RpcType)
grpclog.Printf(" - histogram params: %v", config.HistogramParams)
grpclog.Printf(" - server targets: %v", config.ServerTargets)
grpclog.Infof(" * core list: %v (ignored)", config.CoreList)

grpclog.Infof(" - security params: %v", config.SecurityParams)
grpclog.Infof(" - core limit: %v", config.CoreLimit)
grpclog.Infof(" - payload config: %v", config.PayloadConfig)
grpclog.Infof(" - rpcs per chann: %v", config.OutstandingRpcsPerChannel)
grpclog.Infof(" - channel number: %v", config.ClientChannels)
grpclog.Infof(" - load params: %v", config.LoadParams)
grpclog.Infof(" - rpc type: %v", config.RpcType)
grpclog.Infof(" - histogram params: %v", config.HistogramParams)
grpclog.Infof(" - server targets: %v", config.ServerTargets)
}

func setupClientEnv(config *testpb.ClientConfig) {
Expand Down
16 changes: 8 additions & 8 deletions benchmark/worker/benchmark_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ func printServerConfig(config *testpb.ServerConfig) {
// will always start sync server
// - async server threads
// - core list
grpclog.Printf(" * server type: %v (ignored, always starts sync server)", config.ServerType)
grpclog.Printf(" * async server threads: %v (ignored)", config.AsyncServerThreads)
grpclog.Infof(" * server type: %v (ignored, always starts sync server)", config.ServerType)
grpclog.Infof(" * async server threads: %v (ignored)", config.AsyncServerThreads)
// TODO: use cores specified by CoreList when setting list of cores is supported in go.
grpclog.Printf(" * core list: %v (ignored)", config.CoreList)
grpclog.Infof(" * core list: %v (ignored)", config.CoreList)

grpclog.Printf(" - security params: %v", config.SecurityParams)
grpclog.Printf(" - core limit: %v", config.CoreLimit)
grpclog.Printf(" - port: %v", config.Port)
grpclog.Printf(" - payload config: %v", config.PayloadConfig)
grpclog.Infof(" - security params: %v", config.SecurityParams)
grpclog.Infof(" - core limit: %v", config.CoreLimit)
grpclog.Infof(" - port: %v", config.Port)
grpclog.Infof(" - payload config: %v", config.PayloadConfig)
}

func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchmarkServer, error) {
Expand Down Expand Up @@ -147,7 +147,7 @@ func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchma
}, opts...)
}

grpclog.Printf("benchmark server listening at %v", addr)
grpclog.Infof("benchmark server listening at %v", addr)
addrSplitted := strings.Split(addr, ":")
p, err := strconv.Atoi(addrSplitted[len(addrSplitted)-1])
if err != nil {
Expand Down
30 changes: 15 additions & 15 deletions benchmark/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) er
var bs *benchmarkServer
defer func() {
// Close benchmark server when stream ends.
grpclog.Printf("closing benchmark server")
grpclog.Infof("closing benchmark server")
if bs != nil {
bs.closeFunc()
}
Expand All @@ -96,9 +96,9 @@ func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) er
var out *testpb.ServerStatus
switch argtype := in.Argtype.(type) {
case *testpb.ServerArgs_Setup:
grpclog.Printf("server setup received:")
grpclog.Infof("server setup received:")
if bs != nil {
grpclog.Printf("server setup received when server already exists, closing the existing server")
grpclog.Infof("server setup received when server already exists, closing the existing server")
bs.closeFunc()
}
bs, err = startBenchmarkServer(argtype.Setup, s.serverPort)
Expand All @@ -112,8 +112,8 @@ func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) er
}

case *testpb.ServerArgs_Mark:
grpclog.Printf("server mark received:")
grpclog.Printf(" - %v", argtype)
grpclog.Infof("server mark received:")
grpclog.Infof(" - %v", argtype)
if bs == nil {
return status.Error(codes.InvalidArgument, "server does not exist when mark received")
}
Expand All @@ -134,7 +134,7 @@ func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) er
var bc *benchmarkClient
defer func() {
// Shut down benchmark client when stream ends.
grpclog.Printf("shuting down benchmark client")
grpclog.Infof("shuting down benchmark client")
if bc != nil {
bc.shutdown()
}
Expand All @@ -151,9 +151,9 @@ func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) er
var out *testpb.ClientStatus
switch t := in.Argtype.(type) {
case *testpb.ClientArgs_Setup:
grpclog.Printf("client setup received:")
grpclog.Infof("client setup received:")
if bc != nil {
grpclog.Printf("client setup received when client already exists, shuting down the existing client")
grpclog.Infof("client setup received when client already exists, shuting down the existing client")
bc.shutdown()
}
bc, err = startBenchmarkClient(t.Setup)
Expand All @@ -165,8 +165,8 @@ func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) er
}

case *testpb.ClientArgs_Mark:
grpclog.Printf("client mark received:")
grpclog.Printf(" - %v", t)
grpclog.Infof("client mark received:")
grpclog.Infof(" - %v", t)
if bc == nil {
return status.Error(codes.InvalidArgument, "client does not exist when mark received")
}
Expand All @@ -182,12 +182,12 @@ func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) er
}

func (s *workerServer) CoreCount(ctx context.Context, in *testpb.CoreRequest) (*testpb.CoreResponse, error) {
grpclog.Printf("core count: %v", runtime.NumCPU())
grpclog.Infof("core count: %v", runtime.NumCPU())
return &testpb.CoreResponse{Cores: int32(runtime.NumCPU())}, nil
}

func (s *workerServer) QuitWorker(ctx context.Context, in *testpb.Void) (*testpb.Void, error) {
grpclog.Printf("quitting worker")
grpclog.Infof("quitting worker")
s.stop <- true
return &testpb.Void{}, nil
}
Expand All @@ -200,7 +200,7 @@ func main() {
if err != nil {
grpclog.Fatalf("failed to listen: %v", err)
}
grpclog.Printf("worker listening at port %v", *driverPort)
grpclog.Infof("worker listening at port %v", *driverPort)

s := grpc.NewServer()
stop := make(chan bool)
Expand All @@ -221,8 +221,8 @@ func main() {

if *pprofPort >= 0 {
go func() {
grpclog.Println("Starting pprof server on port " + strconv.Itoa(*pprofPort))
grpclog.Println(http.ListenAndServe("localhost:"+strconv.Itoa(*pprofPort), nil))
grpclog.Infoln("Starting pprof server on port " + strconv.Itoa(*pprofPort))
grpclog.Infoln(http.ListenAndServe("localhost:"+strconv.Itoa(*pprofPort), nil))
}()
}

Expand Down
2 changes: 1 addition & 1 deletion call.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func invoke(ctx context.Context, method string, req, reply interface{}, cc *Clie
// newClientStream, SendMsg, RecvMsg.
firstAttempt := true
for {
csInt, err := newClientStream(ctx, unaryStreamDesc, cc, method, opts...)
csInt, err := cc.NewStream(ctx, unaryStreamDesc, method, opts...)
if err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ func WithInitialConnWindowSize(s int32) DialOption {
}
}

// WithMaxMsgSize returns a DialOption which sets the maximum message size the client can receive. Deprecated: use WithDefaultCallOptions(MaxCallRecvMsgSize(s)) instead.
// WithMaxMsgSize returns a DialOption which sets the maximum message size the client can receive.
//
// Deprecated: use WithDefaultCallOptions(MaxCallRecvMsgSize(s)) instead.
func WithMaxMsgSize(s int) DialOption {
return WithDefaultCallOptions(MaxCallRecvMsgSize(s))
}
Expand Down Expand Up @@ -251,7 +253,8 @@ func withResolverBuilder(b resolver.Builder) DialOption {
}

// WithServiceConfig returns a DialOption which has a channel to read the service configuration.
// DEPRECATED: service config should be received through name resolver, as specified here.
//
// Deprecated: service config should be received through name resolver, as specified here.
// https://github.com/grpc/grpc/blob/master/doc/service_config.md
func WithServiceConfig(c <-chan ServiceConfig) DialOption {
return func(o *dialOptions) {
Expand Down Expand Up @@ -322,6 +325,7 @@ func WithPerRPCCredentials(creds credentials.PerRPCCredentials) DialOption {

// WithTimeout returns a DialOption that configures a timeout for dialing a ClientConn
// initially. This is valid if and only if WithBlock() is present.
//
// Deprecated: use DialContext and context.WithTimeout instead.
func WithTimeout(d time.Duration) DialOption {
return func(o *dialOptions) {
Expand Down
2 changes: 1 addition & 1 deletion grpclb.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...CallOption
ServerStreams: true,
ClientStreams: true,
}
stream, err := NewClientStream(ctx, desc, c.cc, "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...)
stream, err := c.cc.NewStream(ctx, desc, "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...)
if err != nil {
return nil, err
}
Expand Down
6 changes: 2 additions & 4 deletions grpclb/grpclb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ import (
"google.golang.org/grpc/status"
testpb "google.golang.org/grpc/test/grpc_testing"
"google.golang.org/grpc/test/leakcheck"

_ "google.golang.org/grpc/grpclog/glogger"
)

var (
Expand Down Expand Up @@ -847,7 +845,7 @@ func TestGRPCLBStatsUnaryFailedToSend(t *testing.T) {
t.Fatalf("%v.EmptyCall(_, _) = _, %v, want _, <nil>", testC, err)
}
for i := 0; i < countRPC-1; i++ {
grpc.Invoke(context.Background(), failtosendURI, &testpb.Empty{}, nil, cc)
cc.Invoke(context.Background(), failtosendURI, &testpb.Empty{}, nil)
}
})

Expand Down Expand Up @@ -968,7 +966,7 @@ func TestGRPCLBStatsStreamingFailedToSend(t *testing.T) {
}
}
for i := 0; i < countRPC-1; i++ {
grpc.NewClientStream(context.Background(), &grpc.StreamDesc{}, cc, failtosendURI)
cc.NewStream(context.Background(), &grpc.StreamDesc{}, failtosendURI)
}
})

Expand Down
3 changes: 3 additions & 0 deletions grpclog/grpclog.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,21 @@ func Fatalln(args ...interface{}) {
}

// Print prints to the logger. Arguments are handled in the manner of fmt.Print.
//
// Deprecated: use Info.
func Print(args ...interface{}) {
logger.Info(args...)
}

// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf.
//
// Deprecated: use Infof.
func Printf(format string, args ...interface{}) {
logger.Infof(format, args...)
}

// Println prints to the logger. Arguments are handled in the manner of fmt.Println.
//
// Deprecated: use Infoln.
func Println(args ...interface{}) {
logger.Infoln(args...)
Expand Down
2 changes: 2 additions & 0 deletions grpclog/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package grpclog

// Logger mimics golang's standard Logger as an interface.
//
// Deprecated: use LoggerV2.
type Logger interface {
Fatal(args ...interface{})
Expand All @@ -31,6 +32,7 @@ type Logger interface {

// SetLogger sets the logger that is used in grpc. Call only from
// init() functions.
//
// Deprecated: use SetLoggerV2.
func SetLogger(l Logger) {
logger = &loggerWrapper{Logger: l}
Expand Down
Loading

0 comments on commit f8dbc38

Please sign in to comment.