bump go-streamrpc to 0.2, cleanup logging
logging should be user-friendly in INFO mode
This commit is contained in:
+2
-2
@@ -185,7 +185,7 @@ type requestLogger struct {
|
||||
|
||||
func (l requestLogger) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
log := l.log.WithField("method", r.Method).WithField("url", r.URL)
|
||||
log.Info("start")
|
||||
log.Debug("start")
|
||||
if l.handlerFunc != nil {
|
||||
l.handlerFunc(w, r)
|
||||
} else if l.handler != nil {
|
||||
@@ -193,5 +193,5 @@ func (l requestLogger) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
log.Error("no handler or handlerFunc configured")
|
||||
}
|
||||
log.Info("finish")
|
||||
log.Debug("finish")
|
||||
}
|
||||
|
||||
+1
-4
@@ -64,10 +64,7 @@ var STREAMRPC_CONFIG = &streamrpc.ConnConfig{ // FIXME oversight and configurabi
|
||||
RxStructuredMaxLen: 4096 * 4096,
|
||||
RxStreamMaxChunkSize: 4096 * 4096,
|
||||
TxChunkSize: 4096 * 4096,
|
||||
RxTimeout: streamrpc.Timeout{
|
||||
Progress: 10 * time.Second,
|
||||
},
|
||||
TxTimeout: streamrpc.Timeout{
|
||||
Timeout: streamrpc.Timeout{
|
||||
Progress: 10 * time.Second,
|
||||
},
|
||||
}
|
||||
|
||||
+11
-9
@@ -7,11 +7,11 @@ import (
|
||||
"github.com/zrepl/zrepl/config"
|
||||
"github.com/zrepl/zrepl/daemon/connecter"
|
||||
"github.com/zrepl/zrepl/daemon/filters"
|
||||
"github.com/zrepl/zrepl/daemon/logging"
|
||||
"github.com/zrepl/zrepl/daemon/pruner"
|
||||
"github.com/zrepl/zrepl/endpoint"
|
||||
"github.com/zrepl/zrepl/replication"
|
||||
"sync"
|
||||
"github.com/zrepl/zrepl/daemon/logging"
|
||||
)
|
||||
|
||||
type Push struct {
|
||||
@@ -66,11 +66,10 @@ func (j *Push) Run(ctx context.Context) {
|
||||
|
||||
defer log.Info("job exiting")
|
||||
|
||||
log.Debug("wait for wakeups")
|
||||
|
||||
invocationCount := 0
|
||||
outer:
|
||||
for {
|
||||
log.Info("wait for wakeups")
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.WithError(ctx.Err()).Info("context")
|
||||
@@ -86,12 +85,13 @@ outer:
|
||||
func (j *Push) do(ctx context.Context) {
|
||||
|
||||
log := GetLogger(ctx)
|
||||
ctx = logging.WithSubsystemLoggers(ctx, log)
|
||||
|
||||
client, err := streamrpc.NewClient(j.connecter, &streamrpc.ClientConfig{STREAMRPC_CONFIG})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("cannot create streamrpc client")
|
||||
}
|
||||
defer client.Close()
|
||||
defer client.Close(ctx)
|
||||
|
||||
sender := endpoint.NewSender(j.fsfilter, filters.NewAnyFSVFilter())
|
||||
receiver := endpoint.NewRemote(client)
|
||||
@@ -100,15 +100,17 @@ func (j *Push) do(ctx context.Context) {
|
||||
j.replication = replication.NewReplication()
|
||||
j.mtx.Unlock()
|
||||
|
||||
ctx = logging.WithSubsystemLoggers(ctx, log)
|
||||
log.Info("start replication")
|
||||
j.replication.Drive(ctx, sender, receiver)
|
||||
|
||||
// Prune sender
|
||||
senderPruner := j.prunerFactory.BuildSenderPruner(ctx, sender, sender)
|
||||
log.Info("start pruning sender")
|
||||
psCtx := pruner.WithLogger(ctx, pruner.GetLogger(ctx).WithField("prune_side", "sender"))
|
||||
senderPruner := j.prunerFactory.BuildSenderPruner(psCtx, sender, sender) // FIXME ctx as member
|
||||
senderPruner.Prune()
|
||||
|
||||
// Prune receiver
|
||||
receiverPruner := j.prunerFactory.BuildReceiverPruner(ctx, receiver, sender)
|
||||
log.Info("start pruning receiver")
|
||||
prCtx := pruner.WithLogger(ctx, pruner.GetLogger(ctx).WithField("prune_side", "receiver"))
|
||||
receiverPruner := j.prunerFactory.BuildReceiverPruner(prCtx, receiver, sender) // FIXME ctx as member
|
||||
receiverPruner.Prune()
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ func (j *Sink) handleConnection(ctx context.Context, conn net.Conn) {
|
||||
log.WithField("addr", conn.RemoteAddr()).Info("handling connection")
|
||||
defer log.Info("finished handling connection")
|
||||
|
||||
logging.WithSubsystemLoggers(ctx, log)
|
||||
ctx = logging.WithSubsystemLoggers(ctx, log)
|
||||
|
||||
local, err := endpoint.NewReceiver(j.fsmap, filters.NewAnyFSVFilter())
|
||||
if err != nil {
|
||||
|
||||
@@ -28,5 +28,5 @@ func (a twoClassLogAdaptor) Errorf(fmtStr string, args ...interface{}) {
|
||||
}
|
||||
|
||||
func (a twoClassLogAdaptor) Infof(fmtStr string, args ...interface{}) {
|
||||
a.Logger.Info(fmt.Sprintf(fmtStr, args...))
|
||||
a.Logger.Debug(fmt.Sprintf(fmtStr, args...))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user