-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathservice_impl.h
45 lines (35 loc) · 1.45 KB
/
service_impl.h
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
#pragma once
#include <tuple>
#include "nighthawk/common/nighthawk_service_client.h"
#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/common/statusor.h"
#include "api/distributor/distributor.grpc.pb.h"
namespace Nighthawk {
/**
* Implements a real-world distributor gRPC service.
*/
class NighthawkDistributorServiceImpl final
: public nighthawk::NighthawkDistributor::Service,
public Envoy::Logger::Loggable<Envoy::Logger::Id::main> {
public:
/**
* Construct a new gRPC distributor service instance.
*
* @param service_client gRPC client that will be used to communicate with Nighthawk's load
* generator services.
*/
NighthawkDistributorServiceImpl(std::unique_ptr<NighthawkServiceClient> service_client)
: service_client_(std::move(service_client)) {}
grpc::Status DistributedRequestStream(
grpc::ServerContext* context,
grpc::ServerReaderWriter<nighthawk::DistributedResponse, nighthawk::DistributedRequest>*
stream) override;
private:
std::tuple<grpc::Status, nighthawk::DistributedResponse>
handleRequest(const nighthawk::DistributedRequest& request) const;
absl::StatusOr<nighthawk::client::ExecutionResponse>
handleExecutionRequest(const envoy::config::core::v3::Address& service,
const nighthawk::client::ExecutionRequest& request) const;
std::unique_ptr<NighthawkServiceClient> service_client_;
};
} // namespace Nighthawk