blob: da5aff638830042e4994cf1a1e2d1a505b3e562f [file] [log] [blame]
// Interface for a DataSinkService client.
#ifndef PLATFORMS_SYSHEALTH_COLLECTION_FEED_FORWARD_CLIENT_LIB_FEED_CLIENT_INTERFACE_H_
#define PLATFORMS_SYSHEALTH_COLLECTION_FEED_FORWARD_CLIENT_LIB_FEED_CLIENT_INTERFACE_H_
#include <memory>
#include "tlbmc/agent_config_service.pb.h"
#include "tlbmc/data_sink_service.pb.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
namespace platforms_syshealth::collection::feed {
class FeedClientInterface {
public:
virtual ~FeedClientInterface() = default;
// Writes metrics to the DataSinkService.
virtual absl::StatusOr<WriteMetricsResponse> WriteMetrics(
const WriteMetricsRequest& request) = 0;
// Gets policies from the AgentConfigService.
virtual absl::StatusOr<GetPoliciesResponse> GetPolicies(
const GetPoliciesRequest& request) = 0;
// Sets target address for the client. If not set during construction,
// client will be in dry run mode.
virtual void SetTargetAddress(absl::string_view target_address) = 0;
// Returns true if the client is in dry run mode.
virtual bool IsDryRun() const = 0;
};
class AnycastUser {
public:
virtual ~AnycastUser() = default;
virtual void SetAnycastAddress(absl::string_view anycast_address) = 0;
};
class FeedClientAnycastUser : public AnycastUser {
public:
explicit FeedClientAnycastUser(
std::shared_ptr<FeedClientInterface> feed_client)
: feed_client_(feed_client) {}
void SetAnycastAddress(absl::string_view anycast_address) override {
if (feed_client_ == nullptr) {
return;
}
feed_client_->SetTargetAddress(anycast_address);
}
private:
std::shared_ptr<FeedClientInterface> feed_client_;
};
} // namespace platforms_syshealth::collection::feed
#endif // PLATFORMS_SYSHEALTH_COLLECTION_FEED_FORWARD_CLIENT_LIB_FEED_CLIENT_INTERFACE_H_