This commit is contained in:
parent
77c626a7c3
commit
a32b1ef69b
3 changed files with 15 additions and 6 deletions
|
|
@ -141,7 +141,7 @@ func (app *App) Run(ctx context.Context) {
|
||||||
l := len(sendData)
|
l := len(sendData)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
log.WithField("length", l).Debug("Sending parsed data")
|
log.WithField("length", l).Debug("Sending parsed data")
|
||||||
app.network.SendResult(apiClient, sendData)
|
app.network.SendResult(ctx, apiClient, sendData)
|
||||||
sendData = sendData[:0]
|
sendData = sendData[:0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,5 @@ import (
|
||||||
|
|
||||||
type Handler interface {
|
type Handler interface {
|
||||||
RequestTasks(ctx context.Context, client pb.TaskProcessorClient) []shared.TaskResponse
|
RequestTasks(ctx context.Context, client pb.TaskProcessorClient) []shared.TaskResponse
|
||||||
SendResult(client pb.TaskProcessorClient, tasksDone []shared.TaskResult)
|
SendResult(ctx context.Context, client pb.TaskProcessorClient, tasksDone []shared.TaskResult)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,14 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"task-processor/internal/shared"
|
"task-processor/internal/shared"
|
||||||
pb "task-processor/proto/taskProcessor"
|
pb "task-processor/proto/taskProcessor"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *Network) SendResult(client pb.TaskProcessorClient, tasksDone []shared.TaskResult) {
|
func (n *Network) SendResult(ctx context.Context, client pb.TaskProcessorClient, tasksDone []shared.TaskResult) {
|
||||||
stream, err := client.SendResult(context.Background())
|
sendCtx, cancel := context.WithTimeout(ctx, time.Second*60)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
stream, err := client.SendResult(sendCtx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error calling PostMerch: %v", err)
|
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 {
|
//if err = stream.CloseSend(); err != nil {
|
||||||
log.Fatalf("Error closing stream: %v", err)
|
// 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