This commit is contained in:
parent
77c626a7c3
commit
a32b1ef69b
3 changed files with 15 additions and 6 deletions
|
|
@ -5,10 +5,14 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
"task-processor/internal/shared"
|
||||
pb "task-processor/proto/taskProcessor"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (n *Network) SendResult(client pb.TaskProcessorClient, tasksDone []shared.TaskResult) {
|
||||
stream, err := client.SendResult(context.Background())
|
||||
func (n *Network) SendResult(ctx context.Context, client pb.TaskProcessorClient, tasksDone []shared.TaskResult) {
|
||||
sendCtx, cancel := context.WithTimeout(ctx, time.Second*60)
|
||||
defer cancel()
|
||||
|
||||
stream, err := client.SendResult(sendCtx)
|
||||
if err != nil {
|
||||
log.Fatalf("Error calling PostMerch: %v", err)
|
||||
}
|
||||
|
|
@ -29,7 +33,12 @@ func (n *Network) SendResult(client pb.TaskProcessorClient, tasksDone []shared.T
|
|||
}
|
||||
}
|
||||
|
||||
if err = stream.CloseSend(); err != nil {
|
||||
log.Fatalf("Error closing stream: %v", err)
|
||||
//if err = stream.CloseSend(); err != nil {
|
||||
// log.Fatalf("Error closing stream: %v", err)
|
||||
//}
|
||||
|
||||
_, err = stream.CloseAndRecv()
|
||||
if err != nil {
|
||||
log.Fatalf("Error receiving response: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue