blob: b2764cd6ccd90a45c3182e6af23e62b55e7c3ec0 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "loadbalancer.h"
#include "externslobrokpolicy.h"
namespace documentapi {
class LoadBalancerPolicy : public ExternSlobrokPolicy
{
public:
LoadBalancerPolicy(const string& param);
void doSelect(mbus::RoutingContext &context) override;
/**
Finds the TCP address of the target docproc.
@return Returns a hop representing the TCP address of the target docproc, or null if none could be found.
*/
std::pair<string, int> getRecipient(mbus::RoutingContext& context) {
return _loadBalancer->getRecipient(lookup(context, _pattern));
}
void merge(mbus::RoutingContext &context) override;
private:
string _pattern;
string _cluster;
string _session;
std::unique_ptr<LoadBalancer> _loadBalancer;
};
}
|