Skip to content

Commit

Permalink
worker selects message in round-robin
Browse files Browse the repository at this point in the history
  • Loading branch information
ezsilmar committed Apr 18, 2019
1 parent 83c25fe commit 4faac03
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions runner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runner

import (
"context"
"fmt"
"io"
"sync/atomic"
"time"
Expand Down Expand Up @@ -110,12 +111,19 @@ func (w *Worker) makeRequest() error {
if w.mtd.IsClientStreaming() {
_ = w.makeClientStreamingRequest(&ctx, inputs)
}
if w.mtd.IsServerStreaming() {
_ = w.makeServerStreamingRequest(&ctx, (*inputs)[0])

inputsLen := len(*inputs)
if inputsLen == 0 {
return fmt.Errorf("Error: can't create a request without payload. Check your data");
}
inputIdx := int(reqNum % int64(inputsLen))

if w.mtd.IsServerStreaming() {
_ = w.makeServerStreamingRequest(&ctx, (*inputs)[inputIdx])
}
// TODO: handle response?
_, _ = w.stub.InvokeRpc(ctx, w.mtd, (*inputs)[0])
_, _ = w.stub.InvokeRpc(ctx, w.mtd, (*inputs)[inputIdx])

return err
}

Expand Down

0 comments on commit 4faac03

Please sign in to comment.