github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/systembench/network_test_server.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package systembench 12 13 import ( 14 "fmt" 15 "math" 16 "net" 17 18 "github.com/cockroachdb/cockroach/pkg/cli/systembench/systembenchpb" 19 "google.golang.org/grpc" 20 ) 21 22 // ServerOptions holds parameters for server part of 23 // the network test. 24 type ServerOptions struct { 25 Port string 26 } 27 28 // 56 bytes is inline with ping. 29 var serverPayload = 56 30 31 // RunServer runs a server for network benchmarks. 32 func RunServer(serverOptions ServerOptions) error { 33 lis, err := net.Listen("tcp", ":"+serverOptions.Port) 34 if err != nil { 35 return err 36 } 37 s := grpc.NewServer( 38 grpc.MaxRecvMsgSize(math.MaxInt32), 39 grpc.MaxConcurrentStreams(math.MaxInt32), 40 grpc.InitialWindowSize(65535), 41 grpc.InitialConnWindowSize(65535), 42 ) 43 systembench.RegisterPingerServer(s, newPinger()) 44 fmt.Printf("server starting on %s", serverOptions.Port) 45 return s.Serve(lis) 46 }