streamrpc 0.3 + config from daemon/config
This commit is contained in:
@@ -3,9 +3,7 @@ package job
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/problame/go-streamrpc"
|
||||
"github.com/zrepl/zrepl/logger"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Logger = logger.Logger
|
||||
@@ -59,12 +57,3 @@ func WaitWakeup(ctx context.Context) <-chan struct{} {
|
||||
return wc
|
||||
}
|
||||
|
||||
var STREAMRPC_CONFIG = &streamrpc.ConnConfig{ // FIXME oversight and configurability
|
||||
RxHeaderMaxLen: 4096,
|
||||
RxStructuredMaxLen: 4096 * 4096,
|
||||
RxStreamMaxChunkSize: 4096 * 4096,
|
||||
TxChunkSize: 4096 * 4096,
|
||||
Timeout: streamrpc.Timeout{
|
||||
Progress: 10 * time.Second,
|
||||
},
|
||||
}
|
||||
|
||||
+7
-5
@@ -3,7 +3,6 @@ package job
|
||||
import (
|
||||
"context"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/problame/go-streamrpc"
|
||||
"github.com/zrepl/zrepl/config"
|
||||
"github.com/zrepl/zrepl/daemon/connecter"
|
||||
"github.com/zrepl/zrepl/daemon/filters"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
|
||||
type Push struct {
|
||||
name string
|
||||
connecter streamrpc.Connecter
|
||||
clientFactory *connecter.ClientFactory
|
||||
fsfilter endpoint.FSFilter
|
||||
|
||||
prunerFactory *pruner.PrunerFactory
|
||||
@@ -30,7 +29,10 @@ func PushFromConfig(g *config.Global, in *config.PushJob) (j *Push, err error) {
|
||||
j = &Push{}
|
||||
j.name = in.Name
|
||||
|
||||
j.connecter, err = connecter.FromConfig(g, in.Replication.Connect)
|
||||
j.clientFactory, err = connecter.FromConfig(g, in.Replication.Connect)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cannot build client")
|
||||
}
|
||||
|
||||
if j.fsfilter, err = filters.DatasetMapFilterFromConfig(in.Replication.Filesystems); err != nil {
|
||||
return nil, errors.Wrap(err, "cannnot build filesystem filter")
|
||||
@@ -87,9 +89,9 @@ 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})
|
||||
client, err := j.clientFactory.NewClient()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("cannot create streamrpc client")
|
||||
log.WithError(err).Error("factory cannot instantiate streamrpc client")
|
||||
}
|
||||
defer client.Close(ctx)
|
||||
|
||||
|
||||
+3
-2
@@ -15,6 +15,7 @@ import (
|
||||
type Sink struct {
|
||||
name string
|
||||
l serve.ListenerFactory
|
||||
rpcConf *streamrpc.ConnConfig
|
||||
fsmap endpoint.FSMap
|
||||
fsmapInv endpoint.FSFilter
|
||||
}
|
||||
@@ -24,7 +25,7 @@ func SinkFromConfig(g *config.Global, in *config.SinkJob) (s *Sink, err error) {
|
||||
// FIXME multi client support
|
||||
|
||||
s = &Sink{name: in.Name}
|
||||
if s.l, err = serve.FromConfig(g, in.Replication.Serve); err != nil {
|
||||
if s.l, s.rpcConf, err = serve.FromConfig(g, in.Replication.Serve); err != nil {
|
||||
return nil, errors.Wrap(err, "cannot build server")
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ func (j *Sink) handleConnection(ctx context.Context, conn net.Conn) {
|
||||
}
|
||||
|
||||
handler := endpoint.NewHandler(local)
|
||||
if err := streamrpc.ServeConn(ctx, conn, STREAMRPC_CONFIG, handler.Handle); err != nil {
|
||||
if err := streamrpc.ServeConn(ctx, conn, j.rpcConf, handler.Handle); err != nil {
|
||||
log.WithError(err).Error("error serving client")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user