aboutsummaryrefslogtreecommitdiffstats
path: root/defaults/src/vespa/defaults.h
blob: 201a3af5da38c0ef77c01dd31d10adb2b47b2b0b (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <string>
#include <vector>

namespace vespa {

/**
 * This is a class containing the defaults for basic Vespa configuration variables.
 **/
class Defaults {
public:
    /**
     * bootstrap VESPA_HOME (if unset) from argv[0]
     **/
    static void bootstrap(const char *argv0);

    /**
     * Compute the path prefix where Vespa files will live.
     * Note the return value won't end with a "/" - use
     * underVespaHome() to construct sub-directory paths.
     *
     * @return the vespa home directory
     **/
    static const char *vespaHome();

    static std::string underVespaHome(const char *path);

    /**
     * Compute the user name to own directories and run processes.
     * @return the vespa user name
     **/
    static const char *vespaUser();

    /**
     * Compute the host name that identifies myself.
     * Detection of the hostname is now done before starting any Vespa
     * programs and provided in the environment variable VESPA_HOSTNAME;
     * if that variable isn't set a default of "localhost" is always returned.
     * @return the vespa host name
     **/
    static const char *vespaHostname();

    /**
     * Compute the port number where the Vespa webservice
     * container should be available.
     *
     * @return the vespa webservice port
     **/
    static int vespaWebServicePort();

    /**
     * Compute the base for port numbers where the Vespa services
     * should listen.
     *
     * @return the vespa base number for ports
     **/
    static int vespaPortBase();

    /**
     * Find the hostnames of configservers that are configured
     * @return a list of hostnames
     **/
    static std::vector<std::string> vespaConfigServerHosts();

    /**
     * Find the RPC port for talking to configservers
     *
     * @return the RPC port number
     **/
    static int vespaConfigServerRpcPort();

    /**
     * Find the RPC addresses to configservers that are configured
     * @return a list of RPC specs in the format tcp/{hostname}:{portnumber}
     **/
    static std::vector<std::string> vespaConfigServerRpcAddrs();

    /**
     * Find the URLs to the REST api on configservers
     * @return a list of URLS in the format http://{hostname}:{portnumber}/
     **/
    static std::vector<std::string> vespaConfigServerRestUrls();

    /**
     * Find the RPC address to the local config proxy
     * @return one RPC spec in the format tcp/{hostname}:{portnumber}
     **/
    static std::string vespaConfigProxyRpcAddr();

    /**
     * Get the RPC addresses to all known config sources
     * @return same as vespaConfigProxyRpcAddr + vespaConfigServerRpcAddrs
     **/
    static std::vector<std::string> vespaConfigSourcesRpcAddrs();

    static std::string get_sanitizers();
};

} // namespace vespa