blob: 3be9598b7c8d313bd665abf36f89a7cc3db8f31b (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/stllike/string.h>
#include <cstdint>
#include <vector>
#include <memory>
namespace storage::rpc {
class RpcTarget;
/**
* A pool of RPC targets used for a single node endpoint.
*
* The bucket id associated with a message is used to select the RPC target.
* This ensures the same RPC target is used for all messages to the same bucket to the same node,
* and the RPC target itself handles sequencing of these messages.
*/
class RpcTargetPool {
public:
using RpcTargetVector = std::vector<std::shared_ptr<RpcTarget>>;
private:
RpcTargetVector _targets;
const vespalib::string _spec;
uint32_t _slobrok_gen;
public:
RpcTargetPool(RpcTargetVector&& targets, const vespalib::string& spec, uint32_t slobrok_gen);
const vespalib::string& spec() const { return _spec; }
uint32_t slobrok_gen() const { return _slobrok_gen; }
void update_slobrok_gen(uint32_t curr_slobrok_gen) { _slobrok_gen = curr_slobrok_gen; }
std::shared_ptr<RpcTarget> get_target(uint64_t bucket_id) const;
};
}
|