aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/statusreporterdelegate.cpp
blob: 0575574804c14d97c0c7a8f87370e78cfed31832 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "statusreporterdelegate.h"

namespace storage::distributor {

StatusReporterDelegate::StatusReporterDelegate(
        framework::ComponentRegister& compReg,
        const StatusDelegator& delegator,
        const framework::StatusReporter& target)
    : framework::StatusReporter(target.getId(), target.getName()),
      _delegator(delegator),
      _target(target),
      _component(compReg, std::string(target.getId()) + "_status")
{
}

StatusReporterDelegate::~StatusReporterDelegate() = default;

vespalib::string
StatusReporterDelegate::getReportContentType(const framework::HttpUrlPath& path) const
{
    // Implementation must be data race free.
    return _target.getReportContentType(path);
}

bool
StatusReporterDelegate::reportStatus(std::ostream& out,
                                     const framework::HttpUrlPath& path) const
{
    return _delegator.handleStatusRequest(
            DelegatedStatusRequest(_target, path, out));
}

void
StatusReporterDelegate::registerStatusPage()
{
    _component.registerStatusPage(*this);
}

}