aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h
blob: 7d5cbad36d1343efd122406eb8e866836a2cf989 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "i_gid_to_lid_change_listener.h"
#include <vespa/searchlib/common/serialnum.h>
#include <set>
#include <vector>

namespace document { class GlobalId; }

namespace proton {

class IPendingGidToLidChanges;

/*
 * Interface class for registering listeners that get notification when
 * gid to lid mapping changes.
 */
class IGidToLidChangeHandler
{
public:
    using IDestructorCallbackSP = IGidToLidChangeListener::IDestructorCallbackSP;
    using SerialNum = search::SerialNum;
    using GlobalId = document::GlobalId;

    virtual ~IGidToLidChangeHandler();

    /*
     * Add listener unless a listener with matching docTypeName and
     * name already exists.
     */
    virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) = 0;

    /**
     * Remove listeners with matching docTypeName unless name is present in
     * keepNames.
     */
    virtual void removeListeners(const vespalib::string &docTypeName,
                                 const std::set<vespalib::string> &keepNames) = 0;
    /**
     * Notify pending gid to lid mapping change. Passed on to listeners later
     * when force commit has made changes visible.
     */
    virtual void notifyPut(IDestructorCallbackSP context, GlobalId gid, uint32_t lid, SerialNum serial_num) = 0;
    /**
     * Notify removal of gid. Passed on to listeners at once.
     */
    void notifyRemove(IDestructorCallbackSP context, GlobalId gid, SerialNum serialNum);
    virtual void notifyRemoves(IDestructorCallbackSP context, const std::vector<GlobalId> & gids, SerialNum serialNum) = 0;
    virtual std::unique_ptr<IPendingGidToLidChanges> grab_pending_changes() = 0;
};

} // namespace proton