From 6889f441b29275bd270f053fb1962ec1835612cf Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 24 Sep 2018 12:34:53 +0200 Subject: [PATCH] endpoint: support remote ReplicationCursor endpoint --- endpoint/endpoint.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index a92d41a..fb1347a 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -458,6 +458,26 @@ func (s Remote) DestroySnapshots(ctx context.Context, r *pdu.DestroySnapshotsReq return &res, nil } +func (s Remote) ReplicationCursor(ctx context.Context, req *pdu.ReplicationCursorReq) (*pdu.ReplicationCursorRes, error) { + b, err := proto.Marshal(req) + if err != nil { + return nil, err + } + rb, rs, err := s.c.RequestReply(ctx, RPCReplicationCursor, bytes.NewBuffer(b), nil) + if err != nil { + return nil, err + } + if rs != nil { + rs.Close() + return nil, errors.New("response contains unexpected stream") + } + var res pdu.ReplicationCursorRes + if err := proto.Unmarshal(rb.Bytes(), &res); err != nil { + return nil, err + } + return &res, nil +} + // Handler implements the server-side streamrpc.HandlerFunc for a Remote endpoint stub. type Handler struct { ep replication.Endpoint