aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/common/replay_feedtoken_state.h
blob: 4ed0986b83899ed2d8c958bfd07fab5c050f7178 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "feedtoken.h"
#include <vespa/vespalib/util/shared_operation_throttler.h>
#include <vespa/searchcore/proton/feedoperation/feedoperation.h>

namespace proton::feedtoken {

/*
 * Feed token state used during replay. It contains a throttler token
 * which allows the related shared operation throttler to track the completion
 * of the feed operation.
 */
class ReplayState : public IState {
    using SerialNum = search::SerialNum;
    using ThrottlerToken = vespalib::SharedOperationThrottler::Token;

    ThrottlerToken      _throttler_token;
    FeedOperation::Type _type;
    SerialNum           _serial_num;
public:
    ~ReplayState() override;
    ReplayState(ThrottlerToken throttler_token, const FeedOperation& op);
    bool is_replay() const noexcept override;
    void fail() override;
    void setResult(ResultUP result, bool documentWasFound) override;
    const storage::spi::Result &getResult() override;
};

}