Skip to content

Commit

Permalink
feat: added fail_index to AttemptSequenceRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
galz10 authored and leahecole committed Aug 11, 2023
1 parent 3188c8a commit 30f0edc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion schema/google/showcase/v1beta1/sequence.proto
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,19 @@ message AttemptSequenceRequest {
(google.api.resource_reference).type = "showcase.googleapis.com/Sequence",
(google.api.field_behavior) = REQUIRED
];

}

message AttemptStreamingSequenceRequest {
string name = 1 [
(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.
Expand Down
7 changes: 6 additions & 1 deletion server/services/sequence_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 30f0edc

Please sign in to comment.