blob: 917531f578b584f52756af78b42fa578b21a95b4 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "rpcserviceaddress.h"
#include <vespa/slobrok/imirrorapi.h>
namespace mbus {
class RPCNetwork;
/**
* An RPCService represents a set of remote sessions matching a service pattern.
* The sessions are monitored using the slobrok. If multiple sessions are
* available, round robin is used to balance load between them.
*/
class RPCService {
private:
using Mirror = slobrok::api::IMirrorAPI ;
string _serviceName;
string _connectionSpec;
public:
using UP = std::unique_ptr<RPCService>;
RPCService(const RPCService &) = delete;
RPCService & operator = (const RPCService &) = delete;
/**
* Create a new RPCService backed by the given network and using
* the given service pattern.
*
* @param mirror The naming server to send queries to.
* @param pattern The pattern to use when querying.
*/
RPCService(const Mirror &mirror, const string &pattern);
~RPCService();
/**
* Resolve a concrete address from this service. This service may represent
* multiple remote sessions, so this will select one that is online.
*
* @return A concrete service address.
*/
RPCServiceAddress::UP make_address();
bool isValid() const { return ! _connectionSpec.empty(); }
};
} // namespace mbus
|