mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 01:44:43 +01:00
rpc: logging for bytestream listener
This commit is contained in:
parent
53b3a940ec
commit
feabf1abcd
@ -117,7 +117,7 @@ func doSink(c *cli.Context) (err error) {
|
|||||||
PullMapping: findMapping(conf.PullACLs),
|
PullMapping: findMapping(conf.PullACLs),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = rpc.ListenByteStreamRPC(sshByteStream, handler); err != nil {
|
if err = rpc.ListenByteStreamRPC(sshByteStream, handler, sinkLogger); err != nil {
|
||||||
//os.Exit(1)
|
//os.Exit(1)
|
||||||
err = cli.NewExitError(err, 1)
|
err = cli.NewExitError(err, 1)
|
||||||
defaultLog.Printf("listenbytestreamerror: %#v\n", err)
|
defaultLog.Printf("listenbytestreamerror: %#v\n", err)
|
||||||
|
@ -27,12 +27,17 @@ type RPCHandler interface {
|
|||||||
HandleIncrementalTransferRequest(r IncrementalTransferRequest) (io.Reader, error)
|
HandleIncrementalTransferRequest(r IncrementalTransferRequest) (io.Reader, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Logger interface {
|
||||||
|
Printf(format string, args ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
const ByteStreamRPCProtocolVersion = 1
|
const ByteStreamRPCProtocolVersion = 1
|
||||||
|
|
||||||
type ByteStreamRPC struct {
|
type ByteStreamRPC struct {
|
||||||
conn io.ReadWriteCloser
|
conn io.ReadWriteCloser
|
||||||
encoder *json.Encoder
|
encoder *json.Encoder
|
||||||
decoder *json.Decoder
|
decoder *json.Decoder
|
||||||
|
log Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectByteStreamRPC(conn io.ReadWriteCloser) (RPCRequester, error) {
|
func ConnectByteStreamRPC(conn io.ReadWriteCloser) (RPCRequester, error) {
|
||||||
@ -52,7 +57,7 @@ func ConnectByteStreamRPC(conn io.ReadWriteCloser) (RPCRequester, error) {
|
|||||||
return rpc, nil
|
return rpc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListenByteStreamRPC(conn io.ReadWriteCloser, handler RPCHandler) error {
|
func ListenByteStreamRPC(conn io.ReadWriteCloser, handler RPCHandler, log Logger) error {
|
||||||
|
|
||||||
// A request consists of two subsequent JSON objects
|
// A request consists of two subsequent JSON objects
|
||||||
// Object 1: RequestHeader => contains type of Request Body
|
// Object 1: RequestHeader => contains type of Request Body
|
||||||
|
Loading…
Reference in New Issue
Block a user