aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/vespa/documentapi/messagebus/messages/feedanswer.h
blob: efaaf6428308fa1b89d00ca1cc387bba61201501 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/documentapi/common.h>

namespace documentapi {

/**
 * This class contains the response to a feed command from a single
 * RTC node.
 */
class FeedAnswer {
public:
    /**
     * How the feed command was handled. Be careful about enum
     * ordering as this will be serialized. Add new values at the end.
     */
    enum Handling {
        UNKNOWN = 0,
        HANDLED_OK,
        HANDLED_MISSED_PREV,
        HANDLED_AS_HINT,
        IGNORED_DUP,
        IGNORED_SOF_REALTIME,
        IGNORED_LABEL_MISMATCH,
        ERROR_TOOLOW_INCREMENT,
        ERROR_TOOHIGH_INCREMENT,
        ERROR_INCREMENT_IN_BATCHMODE,
        ERROR_MISSING_SOF_FOR_EOF,
        ERROR_WRONG_SOF_FOR_EOF,
        ERROR_WRITING_LABEL,
        HANDLED_AS_PROBE
    };

public:
    /**
     * Constructs an empty feed answer.
     */
    FeedAnswer();

    /**
     * Constructs a complete feed answer.
     *
     * @param answerCode The code per the enum above.
     * @param wantedIncrement The increment of the current feed transaction.
     * @param recipient The name of the RTC node.
     * @param moreInfo Arbitrary additional info.
     */
    FeedAnswer(int answerCode, int wantedIncrement,
               const string& recipient,
               const string& moreInfo);

    /**
     * Destructor. Frees any allocated resources.
     */
    virtual ~FeedAnswer();

    /**
     * Returns the numerical code of this answer.
     *
     * @return The code.
     */
    int getAnswerCode() const;

    /**
     * Returns the increment of the feed transaction that the RTC is
     * currently processing.
     *
     * @param The increment.
     */
    int getWantedIncrement() const;

    /**
     * Returns the name of the RTC node whose answer this is.
     *
     * @return The recipient name.
     */
    const string& getRecipient() const;

    /**
     * Returns any additional info added to the answer.
     *
     * @return The additional data.
     */
    const string& getMoreInfo() const;

private:
    int _answerCode;        // The code of this answer.
    int _wantedIncrement;   // The increment of the current feed.
    string _recipient; // The name of the RTC node.
    string _moreInfo;  // Any additional data.
};

}