Skip to content

Commit

Permalink
chore: Pull out headers in the public const file
Browse files Browse the repository at this point in the history
Bug: 374727613
Change-Id: I751f39f918a92c02a3fde33d9ca2903747eb9dcc
GitOrigin-RevId: fadf1792b826e350d644da1d7d37190c975458be
  • Loading branch information
lx3-g authored and copybara-github committed Dec 12, 2024
1 parent c9db19a commit 6fcc3ff
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cc_library(
deps = [
"//components/data/converters:cbor_converter",
"//components/util:request_context",
"//public:constants",
"//public/applications/pa:response_utils",
"//public/query/v2:get_values_v2_cc_grpc",
"@com_google_absl//absl/status:statusor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "components/data_server/request_handler/content_type/cbor_encoder.h"
#include "components/data_server/request_handler/content_type/json_encoder.h"
#include "components/data_server/request_handler/content_type/proto_encoder.h"
#include "public/constants.h"

namespace kv_server {

Expand Down
16 changes: 0 additions & 16 deletions components/data_server/request_handler/content_type/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@
#include "public/query/v2/get_values_v2.grpc.pb.h"

namespace kv_server {

// Header in clear text http request/response that indicates which format is
// used by the payload. The more common "Content-Type" header is not used
// because most importantly that has CORS implications, and in addition, may not
// be forwarded by Envoy to gRPC.
inline constexpr std::string_view kKVContentTypeHeader = "kv-content-type";

// Protobuf Content Type Header Value.
inline constexpr std::string_view kContentEncodingProtoHeaderValue =
"message/ad-auction-trusted-signals-request+proto";
// Json Content Type Header Value.
inline constexpr std::string_view kContentEncodingJsonHeaderValue =
"message/ad-auction-trusted-signals-request+json";
inline constexpr std::string_view kContentEncodingCborHeaderValue =
"message/ad-auction-trusted-signals-request";

// Encodes and decodes V2 requests and responses.
class V2EncoderDecoder {
public:
Expand Down
16 changes: 16 additions & 0 deletions public/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ inline constexpr absl::string_view kKVOhttpResponseLabel =

constexpr std::string_view kServiceName = "kv-server";

// Header in clear text http request/response that indicates which format is
// used by the payload. The more common "Content-Type" header is not used
// because most importantly that has CORS implications, and in addition, may not
// be forwarded by Envoy to gRPC.
inline constexpr std::string_view kKVContentTypeHeader = "kv-content-type";

// Protobuf Content Type Header Value.
inline constexpr std::string_view kContentEncodingProtoHeaderValue =
"message/ad-auction-trusted-signals-request+proto";
// Json Content Type Header Value.
inline constexpr std::string_view kContentEncodingJsonHeaderValue =
"message/ad-auction-trusted-signals-request+json";
// Cbor Content Type Header Value.
inline constexpr std::string_view kContentEncodingCborHeaderValue =
"message/ad-auction-trusted-signals-request";

// Returns a compiled logical sharding config file name regex defined as
// follows:
//
Expand Down
1 change: 1 addition & 0 deletions tools/request_simulation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ cc_library(
hdrs = ["grpc_client.h"],
deps = [
"//components/data_server/request_handler:get_values_v2_handler",
"//public:constants",
"@com_github_grpc_grpc//:grpc++",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/status:statusor",
Expand Down
1 change: 1 addition & 0 deletions tools/request_simulation/grpc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "components/data_server/request_handler/get_values_v2_handler.h"
#include "grpcpp/generic/generic_stub.h"
#include "grpcpp/grpcpp.h"
#include "public/constants.h"
#include "src/google/protobuf/message.h"

namespace kv_server {
Expand Down
4 changes: 2 additions & 2 deletions tools/request_simulation/request_simulation_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ABSL_FLAG(bool, use_default_generation_id, true,

namespace kv_server {

constexpr char* kServiceName = "request-simulation";
constexpr char* kRequestSimulationServiceName = "request-simulation";
constexpr char* kTestingServer = "testing.server";
constexpr int kMetricsExportIntervalInMs = 5000;
constexpr int kMetricsExportTimeoutInMs = 500;
Expand Down Expand Up @@ -397,7 +397,7 @@ void RequestSimulationSystem::InitializeTelemetry() {
std::chrono::milliseconds(kMetricsExportTimeoutInMs);
auto server_address = absl::GetFlag(FLAGS_server_address);
const auto attributes = ResourceAttributes{
{semantic_conventions::kServiceName, kServiceName},
{semantic_conventions::kServiceName, kRequestSimulationServiceName},
{semantic_conventions::kServiceVersion, std::string(BuildVersion())},
{semantic_conventions::kHostArch, std::string(BuildPlatform())},
{kTestingServer, server_address}};
Expand Down

0 comments on commit 6fcc3ff

Please sign in to comment.