8000 fix: replace TaskManagementClient with WorkerClient in Connor by nikonov1101 · Pull Request #1862 · sonm-io/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: replace TaskManagementClient with WorkerClient in Connor #1862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions connor/antifraud/log_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"go.uber.org/atomic"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)

type logProcessor struct {
log *zap.Logger
cfg *LogProcessorConfig
deal *types.Deal
taskID string
taskClient sonm.TaskManagementClient
taskClient sonm.WorkerClient
hashrateEWMA metrics.EWMA
startTime time.Time

Expand All @@ -44,7 +45,7 @@ func newLogProcessor(cfg *LogProcessorConfig, log *zap.Logger, conn *grpc.Client
cfg: cfg,
deal: deal,
taskID: taskID,
taskClient: sonm.NewTaskManagementClient(conn),
taskClient: sonm.NewWorkerClient(conn),
hashrateEWMA: metrics.NewEWMA(1 - math.Exp(-5.0/cfg.DecayTime)),
startTime: time.Now(),
hashrate: atomic.NewFloat64(float64(deal.BenchmarkValue())),
Expand Down Expand Up @@ -150,9 +151,13 @@ func (m *logProcessor) fetchLogs(ctx context.Context) error {
}

m.log.Debug("requesting logs", zap.Int("count", failureCount))
cli, err := m.taskClient.Logs(ctx, request)
ctx = metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{
"deal": m.deal.GetId().Unwrap().String(),
}))
cli, err := m.taskClient.TaskLogs(ctx, request)
if err != nil {
m.hashrate.Store(0.)
failureCount++
m.log.Warn("failed to fetch logs from the task", zap.Error(err), zap.Int("count", failureCount))
continue
}
Expand Down
0