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

#pragma once

#include "propertiesmap.h"
#include "trace.h"

namespace search::engine {

class Request
{
public:
    Request(RelativeTime relativeTime);
    Request(RelativeTime relativeTime, uint32_t reservePropMaps);
    Request(const Request &) = delete;
    Request & operator =(const Request &) = delete;
    virtual ~Request();
    void setTimeout(vespalib::duration timeout);
    vespalib::steady_time getStartTime() const { return _relativeTime.timeOfDawn(); }
    vespalib::steady_time getTimeOfDoom() const { return _timeOfDoom; }
    vespalib::duration getTimeout() const { return _timeOfDoom - getStartTime(); }
    vespalib::duration getTimeUsed() const;
    vespalib::duration getTimeLeft() const;
    bool expired() const { return getTimeLeft() <= vespalib::duration::zero(); }

    const vespalib::stringref getStackRef() const {
        return vespalib::stringref(stackDump.data(), stackDump.size());
    }

    void setTraceLevel(uint32_t level, uint32_t minLevel) const {
        _trace.setLevel(level);
        _trace.start(minLevel);
    }

    Trace & trace() const { return _trace; }
private:
    RelativeTime           _relativeTime;
    vespalib::steady_time  _timeOfDoom;
public:
    /// Everything here should move up to private section and have accessors
    bool               dumpFeatures;
    vespalib::string   ranking;
    vespalib::string   location;
    PropertiesMap      propertiesMap;
    std::vector<char>  stackDump;
private:
    mutable Trace      _trace;
};

}