aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/i_operation_storer.h
blob: a9f7c8279e43e15046f479fc1ef6ec87ef837d79 (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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

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

namespace proton {

class FeedOperation;

/**
 * Interface for a component assigning serial numbers and storing feed operations.
 */
struct IOperationStorer
{
    using DoneCallback = search::transactionlog::Writer::DoneCallback;
    using CommitResult = search::transactionlog::Writer::CommitResult;
    virtual ~IOperationStorer() = default;

    /**
     * Assign serial number to (if not set) and store the given operation.
     */
    virtual void appendOperation(const FeedOperation &op, DoneCallback onDone) = 0;
    [[nodiscard]] virtual CommitResult startCommit(DoneCallback onDone) = 0;
    [[nodiscard]] CommitResult appendAndCommitOperation(const FeedOperation &op, DoneCallback onDone) {
        appendOperation(op, DoneCallback());
        return startCommit(std::move(onDone));
    }
};

} // namespace proton