| #ifndef PLATFORMS_SYSHEALTH_COLLECTION_FEED_FORWARD_CLIENT_LIB_FEED_CLIENT_GRPC_H_ |
| #define PLATFORMS_SYSHEALTH_COLLECTION_FEED_FORWARD_CLIENT_LIB_FEED_CLIENT_GRPC_H_ |
| |
| #include <memory> |
| #include <utility> |
| |
| #include "tlbmc/feed_client.pb.h" |
| #include "tlbmc/feed_client_interface.h" |
| #include "agent_config_service.grpc.pb.h" |
| #include "data_sink_service.grpc.pb.h" |
| #include "absl/status/statusor.h" |
| #include "grpcpp/security/credentials.h" |
| |
| namespace platforms_syshealth::collection::feed { |
| |
| // If its bazel build then use |
| // platforms_syshealth::collection::feed::grpc::DataSinkService::StubInterface |
| // else use grpc::DataSinkService::StubInterface; |
| #if defined(BAZEL_BUILD) |
| using DataSinkService = grpc::DataSinkService; |
| using AgentConfigService = grpc::AgentConfigService; |
| #else |
| using DataSinkService = platforms_syshealth::collection::feed::DataSinkService; |
| using AgentConfigService = |
| platforms_syshealth::collection::feed::AgentConfigService; |
| #endif |
| |
| class FeedClientGrpc : public FeedClientInterface { |
| public: |
| FeedClientGrpc( |
| const FeedClientConfig& config, |
| const std::shared_ptr<::grpc::ChannelCredentials>& credentials); |
| // For testing only. |
| FeedClientGrpc( |
| std::unique_ptr<DataSinkService::StubInterface> stub, |
| std::unique_ptr<AgentConfigService::StubInterface> agent_config_stub) |
| : stub_(std::move(stub)), |
| agent_config_stub_(std::move(agent_config_stub)) {} |
| |
| absl::StatusOr<WriteMetricsResponse> WriteMetrics( |
| const WriteMetricsRequest& request) override; |
| |
| absl::StatusOr<GetPoliciesResponse> GetPolicies( |
| const GetPoliciesRequest& request) override; |
| |
| private: |
| FeedClientConfig config_; |
| std::unique_ptr<DataSinkService::StubInterface> stub_; |
| std::unique_ptr<AgentConfigService::StubInterface> agent_config_stub_; |
| }; |
| |
| } // namespace platforms_syshealth::collection::feed |
| |
| #endif // PLATFORMS_SYSHEALTH_COLLECTION_FEED_FORWARD_CLIENT_LIB_FEED_CLIENT_GRPC_H_ |