basic app
This commit is contained in:
parent
0a6e246a5c
commit
8d6c2b6687
30 changed files with 1469 additions and 0 deletions
38
internal/network/recieve.go
Normal file
38
internal/network/recieve.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
"io"
|
||||
"parsing-service/internal/shared"
|
||||
pb "parsing-service/proto/taskProcessor"
|
||||
)
|
||||
|
||||
func (n *Network) RequestTasks(ctx context.Context, client pb.TaskProcessorClient) []shared.TaskResponse {
|
||||
var tasksList []shared.TaskResponse
|
||||
stream, err := client.RequestTask(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
log.WithField("err", err).Error("Error calling Request Tasks")
|
||||
return nil
|
||||
}
|
||||
|
||||
for {
|
||||
response, err := stream.Recv()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
log.WithField("err", err).Error("Error receiving response")
|
||||
return nil
|
||||
}
|
||||
|
||||
tasksList = append(tasksList, shared.TaskResponse{
|
||||
MerchUuid: response.MerchUuid,
|
||||
OriginSurugayaLink: response.OriginSurugayaLink,
|
||||
OriginMandarakeLink: response.OriginMandarakeLink,
|
||||
})
|
||||
log.WithField("entry added", response.MerchUuid).Debug("gRPC Receive")
|
||||
}
|
||||
return tasksList
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue