diff --git a/internal/grpc/retry/testpb/BUILD.bazel b/internal/grpc/retry/testpb/BUILD.bazel new file mode 100644 index 000000000000..7d37e6fc645c --- /dev/null +++ b/internal/grpc/retry/testpb/BUILD.bazel @@ -0,0 +1,39 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("//dev:go_defs.bzl", "go_test") + +go_library( + name = "testpb", + srcs = [ + "interceptor_suite.go", + "pingservice.go", + "test.manual_validator.pb.go", + "test.pb.go", + "test_grpc.pb.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/internal/grpc/retry/testpb", + visibility = ["//:__subpackages__"], + deps = [ + "@com_github_stretchr_testify//require", + "@com_github_stretchr_testify//suite", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", + "@org_golang_google_grpc//status", + "@org_golang_google_protobuf//reflect/protoreflect", + "@org_golang_google_protobuf//runtime/protoimpl", + ], +) + +go_test( + name = "testpb_test", + srcs = ["pingservice_test.go"], + embed = [":testpb"], + deps = [ + "@com_github_stretchr_testify//require", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//credentials/insecure", + "@org_golang_google_grpc//status", + ], +) diff --git a/internal/grpc/retry/testpb/interceptor_suite.go b/internal/grpc/retry/testpb/interceptor_suite.go new file mode 100644 index 000000000000..fb70e8c71595 --- /dev/null +++ b/internal/grpc/retry/testpb/interceptor_suite.go @@ -0,0 +1,233 @@ +// Copyright (c) The go-grpc-middleware Authors. +// Licensed under the Apache License 2.0. + +package testpb + +import ( + "context" + "crypto/rand" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "flag" + "math/big" + "net" + "sync" + "time" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" +) + +var ( + flagTls = flag.Bool("use_tls", true, "whether all gRPC middleware tests should use tls") + + certPEM []byte + keyPEM []byte +) + +// InterceptorTestSuite is a testify/Suite that starts a gRPC PingService server and a client. +type InterceptorTestSuite struct { + suite.Suite + + TestService TestServiceServer + ServerOpts []grpc.ServerOption + ClientOpts []grpc.DialOption + + serverAddr string + ServerListener net.Listener + Server *grpc.Server + clientConn *grpc.ClientConn + Client TestServiceClient + + restartServerWithDelayedStart chan time.Duration + serverRunning chan bool + + cancels []context.CancelFunc +} + +func (s *InterceptorTestSuite) SetupSuite() { + s.restartServerWithDelayedStart = make(chan time.Duration) + s.serverRunning = make(chan bool) + + s.serverAddr = "127.0.0.1:0" + var err error + certPEM, keyPEM, err = generateCertAndKey([]string{"localhost", "example.com"}) // CI:LOCALHOST_OK + require.NoError(s.T(), err, "unable to generate test certificate/key") + + go func() { + for { + var err error + s.ServerListener, err = net.Listen("tcp", s.serverAddr) + s.serverAddr = s.ServerListener.Addr().String() + require.NoError(s.T(), err, "must be able to allocate a port for serverListener") + if *flagTls { + cert, err := tls.X509KeyPair(certPEM, keyPEM) + require.NoError(s.T(), err, "unable to load test TLS certificate") + creds := credentials.NewServerTLSFromCert(&cert) + s.ServerOpts = append(s.ServerOpts, grpc.Creds(creds)) + } + // This is the point where we hook up the interceptor. + s.Server = grpc.NewServer(s.ServerOpts...) + // Create a service if the instantiator hasn't provided one. + if s.TestService == nil { + s.TestService = &TestPingService{} + } + RegisterTestServiceServer(s.Server, s.TestService) + + w := sync.WaitGroup{} + w.Add(1) + go func() { + _ = s.Server.Serve(s.ServerListener) + w.Done() + }() + if s.Client == nil { + s.Client = s.NewClient(s.ClientOpts...) + } + + s.serverRunning <- true + + d := <-s.restartServerWithDelayedStart + s.Server.Stop() + time.Sleep(d) + w.Wait() + } + }() + + select { + case <-s.serverRunning: + case <-time.After(2 * time.Second): + s.T().Fatal("server failed to start before deadline") + } +} + +func (s *InterceptorTestSuite) RestartServer(delayedStart time.Duration) <-chan bool { + s.restartServerWithDelayedStart <- delayedStart + time.Sleep(10 * time.Millisecond) + return s.serverRunning +} + +func (s *InterceptorTestSuite) NewClient(dialOpts ...grpc.DialOption) TestServiceClient { + //lint:ignore SA1019 This is a vendored package, so we shouldn't be modifying it. + newDialOpts := append(dialOpts, grpc.WithBlock()) + var err error + if *flagTls { + cp := x509.NewCertPool() + if !cp.AppendCertsFromPEM(certPEM) { + s.T().Fatal("failed to append certificate") + } + creds := credentials.NewTLS(&tls.Config{ServerName: "localhost", RootCAs: cp}) // CI:LOCALHOST_OK + newDialOpts = append(newDialOpts, grpc.WithTransportCredentials(creds)) + } else { + newDialOpts = append(newDialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) + } + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + //lint:ignore SA1019 This is a vendored package, so we shouldn't be modifying it. + s.clientConn, err = grpc.DialContext(ctx, s.ServerAddr(), newDialOpts...) + require.NoError(s.T(), err, "must not error on client Dial") + return NewTestServiceClient(s.clientConn) +} + +func (s *InterceptorTestSuite) ServerAddr() string { + return s.serverAddr +} + +type ctxTestNumber struct{} + +var ( + ctxTestNumberKey = &ctxTestNumber{} + zero = 0 +) + +func ExtractCtxTestNumber(ctx context.Context) *int { + if v, ok := ctx.Value(ctxTestNumberKey).(*int); ok { + return v + } + return &zero +} + +// UnaryServerInterceptor returns a new unary server interceptors that adds query information logging. +func UnaryServerInterceptor() grpc.UnaryServerInterceptor { + return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { + // newCtx := newContext(ctx, log, opts) + newCtx := ctx + resp, err := handler(newCtx, req) + return resp, err + } +} + +func (s *InterceptorTestSuite) SimpleCtx() context.Context { + ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Second) + ctx = context.WithValue(ctx, ctxTestNumberKey, 1) + s.cancels = append(s.cancels, cancel) + return ctx +} + +func (s *InterceptorTestSuite) DeadlineCtx(deadline time.Time) context.Context { + ctx, cancel := context.WithDeadline(context.TODO(), deadline) + s.cancels = append(s.cancels, cancel) + return ctx +} + +func (s *InterceptorTestSuite) TearDownSuite() { + time.Sleep(10 * time.Millisecond) + if s.ServerListener != nil { + s.Server.GracefulStop() + s.T().Logf("stopped grpc.Server at: %v", s.ServerAddr()) + _ = s.ServerListener.Close() + } + if s.clientConn != nil { + _ = s.clientConn.Close() + } + for _, c := range s.cancels { + c() + } +} + +// generateCertAndKey copied from https://github.com/johanbrandhorst/certify/blob/master/issuers/vault/vault_suite_test.go#L255 +// with minor modifications. +func generateCertAndKey(san []string) ([]byte, []byte, error) { + priv, err := rsa.GenerateKey(rand.Reader, 2048) + if err != nil { + return nil, nil, err + } + notBefore := time.Now() + notAfter := notBefore.Add(time.Hour) + serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) + serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) + if err != nil { + return nil, nil, err + } + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: "example.com", + }, + NotBefore: notBefore, + NotAfter: notAfter, + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + BasicConstraintsValid: true, + DNSNames: san, + } + derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, priv.Public(), priv) + if err != nil { + return nil, nil, err + } + certOut := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE", + Bytes: derBytes, + }) + keyOut := pem.EncodeToMemory(&pem.Block{ + Type: "RSA PRIVATE KEY", + Bytes: x509.MarshalPKCS1PrivateKey(priv), + }) + + return certOut, keyOut, nil +} diff --git a/internal/grpc/retry/testpb/pingservice.go b/internal/grpc/retry/testpb/pingservice.go new file mode 100644 index 000000000000..9130d6c504ad --- /dev/null +++ b/internal/grpc/retry/testpb/pingservice.go @@ -0,0 +1,82 @@ +// Copyright (c) The go-grpc-middleware Authors. +// Licensed under the Apache License 2.0. + +/* +Package `grpc_testing` provides helper functions for testing validators in this package. +*/ + +package testpb + +import ( + "context" + "io" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +const ( + // ListResponseCount is the expected number of responses to PingList + ListResponseCount = 100 +) + +var TestServiceFullName = _TestService_serviceDesc.ServiceName + +// Interface implementation assert. +var _ TestServiceServer = &TestPingService{} + +type TestPingService struct { + UnimplementedTestServiceServer +} + +func (s *TestPingService) PingEmpty(_ context.Context, _ *PingEmptyRequest) (*PingEmptyResponse, error) { + return &PingEmptyResponse{}, nil +} + +func (s *TestPingService) Ping(ctx context.Context, ping *PingRequest) (*PingResponse, error) { + // Modify the ctx value to verify the logger sees the value updated from the initial value + n := ExtractCtxTestNumber(ctx) + if n != nil { + *n = 42 + } + // Send user trailers and headers. + return &PingResponse{Value: ping.Value, Counter: 0}, nil +} + +func (s *TestPingService) PingError(_ context.Context, ping *PingErrorRequest) (*PingErrorResponse, error) { + code := codes.Code(ping.ErrorCodeReturned) + return nil, status.Error(code, "Userspace error") +} + +func (s *TestPingService) PingList(ping *PingListRequest, stream TestService_PingListServer) error { + if ping.ErrorCodeReturned != 0 { + return status.Error(codes.Code(ping.ErrorCodeReturned), "foobar") + } + + // Send user trailers and headers. + for i := 0; i < ListResponseCount; i++ { + if err := stream.Send(&PingListResponse{Value: ping.Value, Counter: int32(i)}); err != nil { + return err + } + } + return nil +} + +func (s *TestPingService) PingStream(stream TestService_PingStreamServer) error { + count := 0 + for { + ping, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return err + } + if err := stream.Send(&PingStreamResponse{Value: ping.Value, Counter: int32(count)}); err != nil { + return err + } + + count += 1 + } + return nil +} diff --git a/internal/grpc/retry/testpb/pingservice_test.go b/internal/grpc/retry/testpb/pingservice_test.go new file mode 100644 index 000000000000..784d7e340598 --- /dev/null +++ b/internal/grpc/retry/testpb/pingservice_test.go @@ -0,0 +1,97 @@ +// Copyright (c) The go-grpc-middleware Authors. +// Licensed under the Apache License 2.0. + +package testpb + +import ( + "context" + "fmt" + "net" + "testing" + "time" + + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" +) + +func TestPingServiceOnWire(t *testing.T) { + stopped := make(chan error) + serverListener, err := net.Listen("tcp", "127.0.0.1:0") + require.NoError(t, err, "must be able to allocate a port for serverListener") + + server := grpc.NewServer() + RegisterTestServiceServer(server, &TestPingService{}) + + go func() { + defer close(stopped) + stopped <- server.Serve(serverListener) + }() + defer func() { + server.Stop() + <-stopped + }() + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + + // This is the point where we hook up the interceptor. + clientConn, err := grpc.DialContext( + ctx, + serverListener.Addr().String(), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithBlock(), + ) + require.NoError(t, err, "must not error on client Dial") + + testClient := NewTestServiceClient(clientConn) + select { + case err := <-stopped: + t.Fatal("gRPC server stopped prematurely", err) + default: + } + + r, err := testClient.PingEmpty(context.Background(), &PingEmptyRequest{}) + require.NoError(t, err) + require.NotNil(t, r) + + r2, err := testClient.Ping(context.Background(), &PingRequest{Value: "24"}) + require.NoError(t, err) + require.Equal(t, "24", r2.Value) + require.Equal(t, int32(0), r2.Counter) + + _, err = testClient.PingError(context.Background(), &PingErrorRequest{ + ErrorCodeReturned: uint32(codes.Internal), + Value: "24", + }) + require.Error(t, err) + require.Equal(t, codes.Internal, status.Code(err)) + + l, err := testClient.PingList(context.Background(), &PingListRequest{Value: "24"}) + require.NoError(t, err) + for i := 0; i < ListResponseCount; i++ { + r, err := l.Recv() + require.NoError(t, err) + require.Equal(t, "24", r.Value) + require.Equal(t, int32(i), r.Counter) + } + + s, err := testClient.PingStream(context.Background()) + require.NoError(t, err) + for i := 0; i < ListResponseCount; i++ { + require.NoError(t, s.Send(&PingStreamRequest{Value: fmt.Sprintf("%v", i)})) + + r, err := s.Recv() + require.NoError(t, err) + require.Equal(t, fmt.Sprintf("%v", i), r.Value) + require.Equal(t, int32(i), r.Counter) + } + + select { + case err := <-stopped: + t.Fatal("gRPC server stopped prematurely", err) + default: + } +} diff --git a/internal/grpc/retry/testpb/test.manual_validator.pb.go b/internal/grpc/retry/testpb/test.manual_validator.pb.go new file mode 100644 index 000000000000..85125048a217 --- /dev/null +++ b/internal/grpc/retry/testpb/test.manual_validator.pb.go @@ -0,0 +1,68 @@ +// Manual code for validation tests. + +package testpb + +import ( + //nolint:depguard This is a vendored package, so we shouldn't modify it to the Sourcegraph errors package. + "errors" + "math" +) + +func (x *PingRequest) Validate(bool) error { + if x.SleepTimeMs > 10000 { + return errors.New("cannot sleep for more than 10s") + } + return nil +} + +func (x *PingErrorRequest) Validate() error { + if x.SleepTimeMs > 10000 { + return errors.New("cannot sleep for more than 10s") + } + return nil +} + +func (x *PingListRequest) Validate(bool) error { + if x.SleepTimeMs > 10000 { + return errors.New("cannot sleep for more than 10s") + } + return nil +} + +func (x *PingStreamRequest) Validate(bool) error { + if x.SleepTimeMs > 10000 { + return errors.New("cannot sleep for more than 10s") + } + return nil +} + +// Validate implements the legacy validation interface from protoc-gen-validate. +func (x *PingResponse) Validate() error { + if x.Counter > math.MaxInt16 { + return errors.New("ping allocation exceeded") + } + return nil +} + +// ValidateAll implements the new ValidateAll interface from protoc-gen-validate. +func (x *PingResponse) ValidateAll() error { + if x.Counter > math.MaxInt16 { + return errors.New("ping allocation exceeded") + } + return nil +} + +var ( + GoodPing = &PingRequest{Value: "something", SleepTimeMs: 9999} + GoodPingError = &PingErrorRequest{Value: "something", SleepTimeMs: 9999} + GoodPingList = &PingListRequest{Value: "something", SleepTimeMs: 9999} + GoodPingStream = &PingStreamRequest{Value: "something", SleepTimeMs: 9999} + + BadPing = &PingRequest{Value: "something", SleepTimeMs: 10001} + BadPingError = &PingErrorRequest{Value: "something", SleepTimeMs: 10001} + BadPingList = &PingListRequest{Value: "something", SleepTimeMs: 10001} + BadPingStream = &PingStreamRequest{Value: "something", SleepTimeMs: 10001} + + GoodPingResponse = &PingResponse{Counter: 100} + BadPingResponse = &PingResponse{Counter: math.MaxInt16 + 1} +) diff --git a/internal/grpc/retry/testpb/test.pb.go b/internal/grpc/retry/testpb/test.pb.go new file mode 100644 index 000000000000..83b5de05cdfc --- /dev/null +++ b/internal/grpc/retry/testpb/test.pb.go @@ -0,0 +1,848 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v4.22.0 +// source: test.proto + +package testpb + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PingEmptyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PingEmptyRequest) Reset() { + *x = PingEmptyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingEmptyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingEmptyRequest) ProtoMessage() {} + +func (x *PingEmptyRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingEmptyRequest.ProtoReflect.Descriptor instead. +func (*PingEmptyRequest) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{0} +} + +type PingEmptyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PingEmptyResponse) Reset() { + *x = PingEmptyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingEmptyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingEmptyResponse) ProtoMessage() {} + +func (x *PingEmptyResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingEmptyResponse.ProtoReflect.Descriptor instead. +func (*PingEmptyResponse) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{1} +} + +type PingRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + SleepTimeMs int32 `protobuf:"varint,2,opt,name=sleep_time_ms,json=sleepTimeMs,proto3" json:"sleep_time_ms,omitempty"` + ErrorCodeReturned uint32 `protobuf:"varint,3,opt,name=error_code_returned,json=errorCodeReturned,proto3" json:"error_code_returned,omitempty"` +} + +func (x *PingRequest) Reset() { + *x = PingRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingRequest) ProtoMessage() {} + +func (x *PingRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. +func (*PingRequest) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{2} +} + +func (x *PingRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingRequest) GetSleepTimeMs() int32 { + if x != nil { + return x.SleepTimeMs + } + return 0 +} + +func (x *PingRequest) GetErrorCodeReturned() uint32 { + if x != nil { + return x.ErrorCodeReturned + } + return 0 +} + +type PingResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` +} + +func (x *PingResponse) Reset() { + *x = PingResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingResponse) ProtoMessage() {} + +func (x *PingResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. +func (*PingResponse) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{3} +} + +func (x *PingResponse) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingResponse) GetCounter() int32 { + if x != nil { + return x.Counter + } + return 0 +} + +type PingErrorRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + SleepTimeMs int32 `protobuf:"varint,2,opt,name=sleep_time_ms,json=sleepTimeMs,proto3" json:"sleep_time_ms,omitempty"` + ErrorCodeReturned uint32 `protobuf:"varint,3,opt,name=error_code_returned,json=errorCodeReturned,proto3" json:"error_code_returned,omitempty"` +} + +func (x *PingErrorRequest) Reset() { + *x = PingErrorRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingErrorRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingErrorRequest) ProtoMessage() {} + +func (x *PingErrorRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingErrorRequest.ProtoReflect.Descriptor instead. +func (*PingErrorRequest) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{4} +} + +func (x *PingErrorRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingErrorRequest) GetSleepTimeMs() int32 { + if x != nil { + return x.SleepTimeMs + } + return 0 +} + +func (x *PingErrorRequest) GetErrorCodeReturned() uint32 { + if x != nil { + return x.ErrorCodeReturned + } + return 0 +} + +type PingErrorResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` +} + +func (x *PingErrorResponse) Reset() { + *x = PingErrorResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingErrorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingErrorResponse) ProtoMessage() {} + +func (x *PingErrorResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingErrorResponse.ProtoReflect.Descriptor instead. +func (*PingErrorResponse) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{5} +} + +func (x *PingErrorResponse) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingErrorResponse) GetCounter() int32 { + if x != nil { + return x.Counter + } + return 0 +} + +type PingListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + SleepTimeMs int32 `protobuf:"varint,2,opt,name=sleep_time_ms,json=sleepTimeMs,proto3" json:"sleep_time_ms,omitempty"` + ErrorCodeReturned uint32 `protobuf:"varint,3,opt,name=error_code_returned,json=errorCodeReturned,proto3" json:"error_code_returned,omitempty"` +} + +func (x *PingListRequest) Reset() { + *x = PingListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingListRequest) ProtoMessage() {} + +func (x *PingListRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingListRequest.ProtoReflect.Descriptor instead. +func (*PingListRequest) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{6} +} + +func (x *PingListRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingListRequest) GetSleepTimeMs() int32 { + if x != nil { + return x.SleepTimeMs + } + return 0 +} + +func (x *PingListRequest) GetErrorCodeReturned() uint32 { + if x != nil { + return x.ErrorCodeReturned + } + return 0 +} + +type PingListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` +} + +func (x *PingListResponse) Reset() { + *x = PingListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingListResponse) ProtoMessage() {} + +func (x *PingListResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingListResponse.ProtoReflect.Descriptor instead. +func (*PingListResponse) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{7} +} + +func (x *PingListResponse) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingListResponse) GetCounter() int32 { + if x != nil { + return x.Counter + } + return 0 +} + +type PingStreamRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + SleepTimeMs int32 `protobuf:"varint,2,opt,name=sleep_time_ms,json=sleepTimeMs,proto3" json:"sleep_time_ms,omitempty"` + ErrorCodeReturned uint32 `protobuf:"varint,3,opt,name=error_code_returned,json=errorCodeReturned,proto3" json:"error_code_returned,omitempty"` +} + +func (x *PingStreamRequest) Reset() { + *x = PingStreamRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingStreamRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingStreamRequest) ProtoMessage() {} + +func (x *PingStreamRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingStreamRequest.ProtoReflect.Descriptor instead. +func (*PingStreamRequest) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{8} +} + +func (x *PingStreamRequest) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingStreamRequest) GetSleepTimeMs() int32 { + if x != nil { + return x.SleepTimeMs + } + return 0 +} + +func (x *PingStreamRequest) GetErrorCodeReturned() uint32 { + if x != nil { + return x.ErrorCodeReturned + } + return 0 +} + +type PingStreamResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` +} + +func (x *PingStreamResponse) Reset() { + *x = PingStreamResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingStreamResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingStreamResponse) ProtoMessage() {} + +func (x *PingStreamResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingStreamResponse.ProtoReflect.Descriptor instead. +func (*PingStreamResponse) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{9} +} + +func (x *PingStreamResponse) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *PingStreamResponse) GetCounter() int32 { + if x != nil { + return x.Counter + } + return 0 +} + +var File_test_proto protoreflect.FileDescriptor + +var file_test_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x74, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x22, + 0x12, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x77, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, + 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, + 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, + 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, + 0x64, 0x22, 0x3e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x22, 0x7c, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x73, + 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, + 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x22, + 0x43, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7b, 0x0a, 0x0f, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, + 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, + 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, + 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, + 0x64, 0x22, 0x42, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7d, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x22, 0x0a, 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, + 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, + 0x64, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x11, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x65, 0x64, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x32, 0xc6, 0x03, 0x0a, 0x0b, 0x54, + 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x09, 0x50, 0x69, + 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, + 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x58, 0x0a, 0x09, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x23, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x24, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x08, 0x50, 0x69, 0x6e, + 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x22, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, + 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x30, 0x01, 0x12, 0x5f, 0x0a, 0x0a, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x12, 0x24, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, + 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, + 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, + 0x01, 0x30, 0x01, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_test_proto_rawDescOnce sync.Once + file_test_proto_rawDescData = file_test_proto_rawDesc +) + +func file_test_proto_rawDescGZIP() []byte { + file_test_proto_rawDescOnce.Do(func() { + file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData) + }) + return file_test_proto_rawDescData +} + +var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_test_proto_goTypes = []interface{}{ + (*PingEmptyRequest)(nil), // 0: testing.testpb.v1.PingEmptyRequest + (*PingEmptyResponse)(nil), // 1: testing.testpb.v1.PingEmptyResponse + (*PingRequest)(nil), // 2: testing.testpb.v1.PingRequest + (*PingResponse)(nil), // 3: testing.testpb.v1.PingResponse + (*PingErrorRequest)(nil), // 4: testing.testpb.v1.PingErrorRequest + (*PingErrorResponse)(nil), // 5: testing.testpb.v1.PingErrorResponse + (*PingListRequest)(nil), // 6: testing.testpb.v1.PingListRequest + (*PingListResponse)(nil), // 7: testing.testpb.v1.PingListResponse + (*PingStreamRequest)(nil), // 8: testing.testpb.v1.PingStreamRequest + (*PingStreamResponse)(nil), // 9: testing.testpb.v1.PingStreamResponse +} +var file_test_proto_depIdxs = []int32{ + 0, // 0: testing.testpb.v1.TestService.PingEmpty:input_type -> testing.testpb.v1.PingEmptyRequest + 2, // 1: testing.testpb.v1.TestService.Ping:input_type -> testing.testpb.v1.PingRequest + 4, // 2: testing.testpb.v1.TestService.PingError:input_type -> testing.testpb.v1.PingErrorRequest + 6, // 3: testing.testpb.v1.TestService.PingList:input_type -> testing.testpb.v1.PingListRequest + 8, // 4: testing.testpb.v1.TestService.PingStream:input_type -> testing.testpb.v1.PingStreamRequest + 1, // 5: testing.testpb.v1.TestService.PingEmpty:output_type -> testing.testpb.v1.PingEmptyResponse + 3, // 6: testing.testpb.v1.TestService.Ping:output_type -> testing.testpb.v1.PingResponse + 5, // 7: testing.testpb.v1.TestService.PingError:output_type -> testing.testpb.v1.PingErrorResponse + 7, // 8: testing.testpb.v1.TestService.PingList:output_type -> testing.testpb.v1.PingListResponse + 9, // 9: testing.testpb.v1.TestService.PingStream:output_type -> testing.testpb.v1.PingStreamResponse + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_test_proto_init() } +func file_test_proto_init() { + if File_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingEmptyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingEmptyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingErrorRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingErrorResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingStreamRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingStreamResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_test_proto_goTypes, + DependencyIndexes: file_test_proto_depIdxs, + MessageInfos: file_test_proto_msgTypes, + }.Build() + File_test_proto = out.File + file_test_proto_rawDesc = nil + file_test_proto_goTypes = nil + file_test_proto_depIdxs = nil +} diff --git a/internal/grpc/retry/testpb/test_grpc.pb.go b/internal/grpc/retry/testpb/test_grpc.pb.go new file mode 100644 index 000000000000..effb0e2a445a --- /dev/null +++ b/internal/grpc/retry/testpb/test_grpc.pb.go @@ -0,0 +1,295 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package testpb + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// TestServiceClient is the client API for TestService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type TestServiceClient interface { + PingEmpty(ctx context.Context, in *PingEmptyRequest, opts ...grpc.CallOption) (*PingEmptyResponse, error) + Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) + PingError(ctx context.Context, in *PingErrorRequest, opts ...grpc.CallOption) (*PingErrorResponse, error) + PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) + PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) +} + +type testServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient { + return &testServiceClient{cc} +} + +func (c *testServiceClient) PingEmpty(ctx context.Context, in *PingEmptyRequest, opts ...grpc.CallOption) (*PingEmptyResponse, error) { + out := new(PingEmptyResponse) + err := c.cc.Invoke(ctx, "/testing.testpb.v1.TestService/PingEmpty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { + out := new(PingResponse) + err := c.cc.Invoke(ctx, "/testing.testpb.v1.TestService/Ping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testServiceClient) PingError(ctx context.Context, in *PingErrorRequest, opts ...grpc.CallOption) (*PingErrorResponse, error) { + out := new(PingErrorResponse) + err := c.cc.Invoke(ctx, "/testing.testpb.v1.TestService/PingError", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) { + stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[0], "/testing.testpb.v1.TestService/PingList", opts...) + if err != nil { + return nil, err + } + x := &testServicePingListClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type TestService_PingListClient interface { + Recv() (*PingListResponse, error) + grpc.ClientStream +} + +type testServicePingListClient struct { + grpc.ClientStream +} + +func (x *testServicePingListClient) Recv() (*PingListResponse, error) { + m := new(PingListResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[1], "/testing.testpb.v1.TestService/PingStream", opts...) + if err != nil { + return nil, err + } + x := &testServicePingStreamClient{stream} + return x, nil +} + +type TestService_PingStreamClient interface { + Send(*PingStreamRequest) error + Recv() (*PingStreamResponse, error) + grpc.ClientStream +} + +type testServicePingStreamClient struct { + grpc.ClientStream +} + +func (x *testServicePingStreamClient) Send(m *PingStreamRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testServicePingStreamClient) Recv() (*PingStreamResponse, error) { + m := new(PingStreamResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TestServiceServer is the server API for TestService service. +// All implementations must embed UnimplementedTestServiceServer +// for forward compatibility +type TestServiceServer interface { + PingEmpty(context.Context, *PingEmptyRequest) (*PingEmptyResponse, error) + Ping(context.Context, *PingRequest) (*PingResponse, error) + PingError(context.Context, *PingErrorRequest) (*PingErrorResponse, error) + PingList(*PingListRequest, TestService_PingListServer) error + PingStream(TestService_PingStreamServer) error + mustEmbedUnimplementedTestServiceServer() +} + +// UnimplementedTestServiceServer must be embedded to have forward compatible implementations. +type UnimplementedTestServiceServer struct { +} + +func (*UnimplementedTestServiceServer) PingEmpty(context.Context, *PingEmptyRequest) (*PingEmptyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PingEmpty not implemented") +} +func (*UnimplementedTestServiceServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (*UnimplementedTestServiceServer) PingError(context.Context, *PingErrorRequest) (*PingErrorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PingError not implemented") +} +func (*UnimplementedTestServiceServer) PingList(*PingListRequest, TestService_PingListServer) error { + return status.Errorf(codes.Unimplemented, "method PingList not implemented") +} +func (*UnimplementedTestServiceServer) PingStream(TestService_PingStreamServer) error { + return status.Errorf(codes.Unimplemented, "method PingStream not implemented") +} +func (*UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {} + +func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) { + s.RegisterService(&_TestService_serviceDesc, srv) +} + +func _TestService_PingEmpty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingEmptyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServiceServer).PingEmpty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testing.testpb.v1.TestService/PingEmpty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServiceServer).PingEmpty(ctx, req.(*PingEmptyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TestService_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServiceServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testing.testpb.v1.TestService/Ping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServiceServer).Ping(ctx, req.(*PingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TestService_PingError_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingErrorRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServiceServer).PingError(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testing.testpb.v1.TestService/PingError", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServiceServer).PingError(ctx, req.(*PingErrorRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TestService_PingList_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(PingListRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TestServiceServer).PingList(m, &testServicePingListServer{stream}) +} + +type TestService_PingListServer interface { + Send(*PingListResponse) error + grpc.ServerStream +} + +type testServicePingListServer struct { + grpc.ServerStream +} + +func (x *testServicePingListServer) Send(m *PingListResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _TestService_PingStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TestServiceServer).PingStream(&testServicePingStreamServer{stream}) +} + +type TestService_PingStreamServer interface { + Send(*PingStreamResponse) error + Recv() (*PingStreamRequest, error) + grpc.ServerStream +} + +type testServicePingStreamServer struct { + grpc.ServerStream +} + +func (x *testServicePingStreamServer) Send(m *PingStreamResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testServicePingStreamServer) Recv() (*PingStreamRequest, error) { + m := new(PingStreamRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _TestService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "testing.testpb.v1.TestService", + HandlerType: (*TestServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PingEmpty", + Handler: _TestService_PingEmpty_Handler, + }, + { + MethodName: "Ping", + Handler: _TestService_Ping_Handler, + }, + { + MethodName: "PingError", + Handler: _TestService_PingError_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "PingList", + Handler: _TestService_PingList_Handler, + ServerStreams: true, + }, + { + StreamName: "PingStream", + Handler: _TestService_PingStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "test.proto", +} diff --git a/internal/grpc/retry/testpb/v1/BUILD.bazel b/internal/grpc/retry/testpb/v1/BUILD.bazel new file mode 100644 index 000000000000..705b4991205a --- /dev/null +++ b/internal/grpc/retry/testpb/v1/BUILD.bazel @@ -0,0 +1,28 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") + +proto_library( + name = "testpb_proto", + srcs = ["test.proto"], + strip_import_prefix = "/internal", + visibility = ["//:__subpackages__"], +) + +go_proto_library( + name = "testpb_go_proto", + compilers = [ + "//:gen-go-grpc", + "@io_bazel_rules_go//proto:go_proto", + ], + importpath = "github.com/sourcegraph/sourcegraph/internal/grpc/retry/testpb/v1", + proto = ":testpb_proto", + visibility = ["//:__subpackages__"], +) + +go_library( + name = "testpb", + embed = [":testpb_go_proto"], + importpath = "github.com/sourcegraph/sourcegraph/internal/grpc/retry/testpb/v1", + visibility = ["//:__subpackages__"], +) diff --git a/internal/grpc/retry/testpb/v1/test.proto b/internal/grpc/retry/testpb/v1/test.proto new file mode 100644 index 000000000000..64bc4bd83234 --- /dev/null +++ b/internal/grpc/retry/testpb/v1/test.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; + +package testing.testpb.v1; + +option go_package = ".;testpb"; + +message PingEmptyRequest { +} + +message PingEmptyResponse { +} + +message PingRequest { + string value = 1; + int32 sleep_time_ms = 2; + uint32 error_code_returned = 3; +} + +message PingResponse { + string value = 1; + int32 counter = 2; +} + +message PingErrorRequest { + string value = 1; + int32 sleep_time_ms = 2; + uint32 error_code_returned = 3; +} + +message PingErrorResponse { + string value = 1; + int32 counter = 2; +} + +message PingListRequest { + string value = 1; + int32 sleep_time_ms = 2; + uint32 error_code_returned = 3; +} + +message PingListResponse { + string value = 1; + int32 counter = 2; +} + +message PingStreamRequest { + string value = 1; + int32 sleep_time_ms = 2; + uint32 error_code_returned = 3; +} + +message PingStreamResponse { + string value = 1; + int32 counter = 2; +} + +service TestService { + rpc PingEmpty(PingEmptyRequest) returns (PingEmptyResponse) {} + + rpc Ping(PingRequest) returns (PingResponse) {} + + rpc PingError(PingErrorRequest) returns (PingErrorResponse) {} + + rpc PingList(PingListRequest) returns (stream PingListResponse) {} + + rpc PingStream(stream PingStreamRequest) returns (stream PingStreamResponse) {} + +}