aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.h
blob: 882a3b166050782d8ec9fb9fcc44d124d7627da4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "ireplaypackethandler.h"
#include <vespa/searchlib/transactionlog/common.h>

namespace proton {

class FeedOperation;
/**
 * Utility class that deserializes packet entries into feed operations
 * during replay from the transaction log and dispatches the feed operations
 * to a given handler class.
 */
class ReplayPacketDispatcher
{
private:
    using Packet = search::transactionlog::Packet;
    IReplayPacketHandler &_handler;

    template <typename OperationType>
    void replay(OperationType &op, vespalib::nbostream &is, const Packet::Entry &entry);

protected:
    virtual void store(const FeedOperation &op);

public:
    ReplayPacketDispatcher(IReplayPacketHandler &handler);
    virtual ~ReplayPacketDispatcher();

    void replayEntry(const Packet::Entry &entry);
};

} // namespace proton