github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/systembench/network_test_common.go (about)

     1  package systembench
     2  
     3  // Copyright 2018 The Cockroach Authors.
     4  //
     5  // Use of this software is governed by the Business Source License
     6  // included in the file licenses/BSL.txt.
     7  //
     8  // As of the Change Date specified in that file, in accordance with
     9  // the Business Source License, use of this software will be governed
    10  // by the Apache License, Version 2.0, included in the file
    11  // licenses/APL.txt.
    12  
    13  import (
    14  	"context"
    15  	"math/rand"
    16  
    17  	"github.com/cockroachdb/cockroach/pkg/cli/systembench/systembenchpb"
    18  )
    19  
    20  type pinger struct {
    21  	payload []byte
    22  }
    23  
    24  func (p *pinger) Ping(
    25  	_ context.Context, req *systembench.PingRequest,
    26  ) (*systembench.PingResponse, error) {
    27  	return &systembench.PingResponse{Payload: p.payload}, nil
    28  }
    29  
    30  func newPinger() *pinger {
    31  	payload := make([]byte, serverPayload)
    32  	_, _ = rand.Read(payload)
    33  	return &pinger{payload: payload}
    34  }