aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/engine/monitorapi.h
blob: 8af422067fae074074f0d08ebc21befe4bd2ba05 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "monitorrequest.h"
#include "monitorreply.h"

namespace search::engine {

/**
 * A monitor client is the object being notified of the completion of
 * an asynchronous monitor operation.
 **/
class MonitorClient
{
public:
    /**
     * Invoked by the monitor server to indicate the completion of an
     * asynchronous monitor operation.
     *
     * @param reply the monitor reply
     **/
    virtual void pingDone(std::unique_ptr<MonitorReply> reply) = 0;

    /**
     * Empty, needed for subclassing
     **/
    virtual ~MonitorClient() {}
};

/**
 * A monitor server is an object capable of performing a monitor
 * operation.
 **/
class MonitorServer
{
public:
    /**
     * Initiate a monitor operation that can be completed either
     * synchronously or asynchronously. The return value will indicate
     * whether the server selected to perform the operation
     * synchronously or asynchronously. If the return value contains
     * an object, then the operation completed synchronously and no
     * further action will be taken by the server. If the return value
     * did not contain an object, the operation will continue
     * asynchronously, and the given client will be notified when the
     * operation is completed. The server is not allowed to signal an
     * asynchronous completion of the operation in the context of this
     * method invocation.
     *
     * @return actual return value if sync, 'null' if async
     * @param request object containing request parameters
     * @param client the client to be notified of async completion
     **/
    virtual std::unique_ptr<MonitorReply> ping(std::unique_ptr<MonitorRequest> request, MonitorClient &client) = 0;

    /**
     * Empty, needed for subclassing
     **/
    virtual ~MonitorServer() {}
};

}