aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/vespa/messagebus/network/identity.cpp
blob: 5932213375edd0d42a073777ac55f5f38e7d7143 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "identity.h"
#include <vespa/vespalib/util/host_name.h>

namespace mbus {

Identity::Identity(const string &configId) :
    _hostname(),
    _servicePrefix(configId)
{
    _hostname = vespalib::HostName::get();
}

Identity::~Identity() = default;

std::vector<string>
Identity::split(const string &name)
{
    std::vector<string> ret;
    string::size_type pos = 0;
    string::size_type split = name.find_first_of('/');
    while (split != string::npos) {
        ret.push_back(string(name, pos, split - pos));
        pos = split + 1;
        split = name.find_first_of('/', pos);
    }
    ret.push_back(string(name, pos));
    return ret;
}

} // namespace mbus