diff --git a/schema/google/showcase/v1beta1/sequence.proto b/schema/google/showcase/v1beta1/sequence.proto index ecd23b052..addf7f5d6 100644 --- a/schema/google/showcase/v1beta1/sequence.proto +++ b/schema/google/showcase/v1beta1/sequence.proto @@ -217,6 +217,7 @@ message AttemptSequenceRequest { (google.api.resource_reference).type = "showcase.googleapis.com/Sequence", (google.api.field_behavior) = REQUIRED ]; + } message AttemptStreamingSequenceRequest { @@ -224,7 +225,11 @@ message AttemptStreamingSequenceRequest { (google.api.resource_reference).type = "showcase.googleapis.com/StreamingSequence", (google.api.field_behavior) = REQUIRED ]; - + + int32 fail_index = 2 [ + (google.api.resource_reference).type = "showcase.googleapis.com/Sequence", + (google.api.field_behavior) = OPTIONAL + ]; } // The response message for the Echo methods. diff --git a/server/services/sequence_service.go b/server/services/sequence_service.go index 08672affb..4acc156a9 100644 --- a/server/services/sequence_service.go +++ b/server/services/sequence_service.go @@ -202,6 +202,7 @@ func (s *sequenceServerImpl) CreateStreamingSequence(ctx context.Context, in *pb func (s *sequenceServerImpl) AttemptStreamingSequence(in *pb.AttemptStreamingSequenceRequest, stream pb.SequenceService_AttemptStreamingSequenceServer) error { received := time.Now() name := in.GetName() + failIndex := in.GetFailIndex() if name == "" { return status.Errorf( codes.InvalidArgument, @@ -241,7 +242,11 @@ func (s *sequenceServerImpl) AttemptStreamingSequence(in *pb.AttemptStreamingSeq st = status.New(codes.OutOfRange, "Attempt exceeded predefined responses") } - for idx, word := range content { + if failIndex < 0 { + failIndex = 0 + } + + for idx, word := range content[failIndex:] { if idx >= respIndex { break }