aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/vespa/messagebus/network/identity.h
blob: 49ac2000daafc7842a3f46bcffd3ffe0b47b68c5 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/messagebus/common.h>
#include <vector>

namespace mbus {

/**
 * An Identity object is a simple value object containing information
 * about the identity of a Network object within the vespa cluster. It
 * contains the service name prefix used when registering
 * sessions. This class also has some static utility methods for
 * general service name manipulation.
 **/
class Identity
{
private:
    string _hostname;
    string _servicePrefix;

public:
    /**
     * Use config to resolve the identity for the given config
     * id. This is intended to be done once at program
     * startup. Changing the identity of a service requires
     * restart. This method will not mask config exceptions.
     *
     * @return identity for the given config id
     * @param configId application config id
     **/
    Identity(const string &configId);
    ~Identity();

    /**
     * Obtain the hostname held by this object.
     *
     * @return hostname
     **/
    const string &getHostname() const { return _hostname; }

    /**
     * Obtain the service prefix held by this object.
     *
     * @return service prefix
     **/
    const string &getServicePrefix() const { return _servicePrefix; }

    /**
     * Split a service name into its path elements.
     *
     * @return service name path elements
     * @param name the service name
     **/
    static std::vector<string> split(const string &name);
};

} // namespace mbus