simplify naming in endpoint package

This commit is contained in:
Christian Schwarz
2018-08-22 00:52:46 +02:00
parent 70aad0940f
commit 9b537ec704
4 changed files with 42 additions and 71 deletions
+3 -30
View File
@@ -8,7 +8,6 @@ import (
"time"
"context"
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
@@ -176,9 +175,9 @@ func (j *PullJob) doRun(ctx context.Context) {
j.task.Enter("pull")
sender := endpoint.RemoteEndpoint{client}
sender := endpoint.NewRemote(client)
puller, err := endpoint.NewReceiverEndpoint(
puller, err := endpoint.NewReceiver(
j.Mapping,
NewPrefixFilter(j.SnapshotPrefix),
)
@@ -188,10 +187,9 @@ func (j *PullJob) doRun(ctx context.Context) {
return
}
ctx = replication.WithLogger(ctx, replicationLogAdaptor{j.task.Log().WithField("subsystem", "replication")})
ctx = streamrpc.ContextWithLogger(ctx, streamrpcLogAdaptor{j.task.Log().WithField("subsystem", "rpc.protocol")})
ctx = context.WithValue(ctx, contextKeyLog, j.task.Log().WithField("subsystem", "rpc.endpoint"))
ctx = endpoint.WithLogger(ctx, j.task.Log().WithField("subsystem", "rpc.endpoint"))
j.rep = replication.NewReplication()
j.rep.Drive(ctx, sender, puller)
@@ -229,28 +227,3 @@ func (j *PullJob) Pruner(task *Task, side PrunePolicySide, dryRun bool) (p Prune
}
return
}
func closeRPCWithTimeout(task *Task, remote endpoint.RemoteEndpoint, timeout time.Duration, goodbye string) {
task.Log().Info("closing rpc connection")
ch := make(chan error)
go func() {
remote.Close()
ch <- nil
close(ch)
}()
var err error
select {
case <-time.After(timeout):
err = fmt.Errorf("timeout exceeded (%s)", timeout)
case closeRequestErr := <-ch:
err = closeRequestErr
}
if err != nil {
task.Log().WithError(err).Error("error closing connection")
}
return
}