Renamed some defines

pull/6570/head
David Garcia Quintas 9 years ago
parent e644cfddb8
commit 183ba02ce7
  1. 14
      include/grpc/impl/codegen/compression_types.h
  2. 9
      src/core/lib/channel/channel_args.c
  3. 2
      src/cpp/common/channel_arguments.cc
  4. 2
      src/cpp/server/server_builder.cc
  5. 3
      test/core/channel/channel_args_test.c

@ -41,9 +41,10 @@ extern "C" {
#endif #endif
/** To be used in channel arguments */ /** To be used in channel arguments */
#define GRPC_COMPRESSION_ALGORITHM_ARG "grpc.compression_algorithm" #define GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM "grpc.compression_algorithm"
#define GRPC_COMPRESSION_LEVEL_ARG "grpc.compression_level" #define GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL "grpc.compression_level"
#define GRPC_COMPRESSION_ALGORITHM_STATE_ARG "grpc.compression_algorithm_state" #define GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET \
"grpc.compression_algorithm_state"
/* The various compression algorithms supported by gRPC */ /* The various compression algorithms supported by gRPC */
typedef enum { typedef enum {
@ -68,17 +69,18 @@ typedef enum {
typedef struct grpc_compression_options { typedef struct grpc_compression_options {
/** All algs are enabled by default. This option corresponds to the channel /** All algs are enabled by default. This option corresponds to the channel
* argument key behind \a GRPC_COMPRESSION_ALGORITHM_STATE_ARG */ * argument key behind \a GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET
*/
uint32_t enabled_algorithms_bitset; uint32_t enabled_algorithms_bitset;
/** The default channel compression algorithm. It'll be used in the absence of /** The default channel compression algorithm. It'll be used in the absence of
* call specific settings. This option corresponds to the channel argument key * call specific settings. This option corresponds to the channel argument key
* behind \a GRPC_COMPRESSION_ALGORITHM_ARG */ * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM */
grpc_compression_algorithm default_compression_algorithm; grpc_compression_algorithm default_compression_algorithm;
/** The default channel compression level. It'll be used in the absence of /** The default channel compression level. It'll be used in the absence of
* call specific settings. This option corresponds to the channel argument key * call specific settings. This option corresponds to the channel argument key
* behind \a GRPC_COMPRESSION_ALGORITHM_ARG */ * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL */
grpc_compression_algorithm default_compression_level; grpc_compression_algorithm default_compression_level;
} grpc_compression_options; } grpc_compression_options;

@ -170,7 +170,7 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
if (a == NULL) return 0; if (a == NULL) return 0;
for (i = 0; i < a->num_args; ++i) { for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER && if (a->args[i].type == GRPC_ARG_INTEGER &&
!strcmp(GRPC_COMPRESSION_ALGORITHM_ARG, a->args[i].key)) { !strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
return (grpc_compression_algorithm)a->args[i].value.integer; return (grpc_compression_algorithm)a->args[i].value.integer;
break; break;
} }
@ -182,7 +182,7 @@ grpc_channel_args *grpc_channel_args_set_compression_algorithm(
grpc_channel_args *a, grpc_compression_algorithm algorithm) { grpc_channel_args *a, grpc_compression_algorithm algorithm) {
grpc_arg tmp; grpc_arg tmp;
tmp.type = GRPC_ARG_INTEGER; tmp.type = GRPC_ARG_INTEGER;
tmp.key = GRPC_COMPRESSION_ALGORITHM_ARG; tmp.key = GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
tmp.value.integer = algorithm; tmp.value.integer = algorithm;
return grpc_channel_args_copy_and_add(a, &tmp, 1); return grpc_channel_args_copy_and_add(a, &tmp, 1);
} }
@ -196,7 +196,8 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args *a,
size_t i; size_t i;
for (i = 0; i < a->num_args; ++i) { for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER && if (a->args[i].type == GRPC_ARG_INTEGER &&
!strcmp(GRPC_COMPRESSION_ALGORITHM_STATE_ARG, a->args[i].key)) { !strcmp(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
a->args[i].key)) {
*states_arg = &a->args[i].value.integer; *states_arg = &a->args[i].value.integer;
return 1; /* GPR_TRUE */ return 1; /* GPR_TRUE */
} }
@ -222,7 +223,7 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
/* create a new arg */ /* create a new arg */
grpc_arg tmp; grpc_arg tmp;
tmp.type = GRPC_ARG_INTEGER; tmp.type = GRPC_ARG_INTEGER;
tmp.key = GRPC_COMPRESSION_ALGORITHM_STATE_ARG; tmp.key = GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
/* all enabled by default */ /* all enabled by default */
tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
if (state != 0) { if (state != 0) {

@ -85,7 +85,7 @@ void ChannelArguments::Swap(ChannelArguments& other) {
void ChannelArguments::SetCompressionAlgorithm( void ChannelArguments::SetCompressionAlgorithm(
grpc_compression_algorithm algorithm) { grpc_compression_algorithm algorithm) {
SetInt(GRPC_COMPRESSION_ALGORITHM_ARG, algorithm); SetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, algorithm);
} }
// Note: a second call to this will add in front the result of the first call. // Note: a second call to this will add in front the result of the first call.

@ -123,7 +123,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
if (max_message_size_ > 0) { if (max_message_size_ > 0) {
args.SetInt(GRPC_ARG_MAX_MESSAGE_LENGTH, max_message_size_); args.SetInt(GRPC_ARG_MAX_MESSAGE_LENGTH, max_message_size_);
} }
args.SetInt(GRPC_COMPRESSION_ALGORITHM_STATE_ARG, args.SetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
compression_options_.enabled_algorithms_bitset); compression_options_.enabled_algorithms_bitset);
std::unique_ptr<Server> server( std::unique_ptr<Server> server(
new Server(thread_pool.release(), true, max_message_size_, &args)); new Server(thread_pool.release(), true, max_message_size_, &args));

@ -77,7 +77,8 @@ static void test_set_compression_algorithm(void) {
ch_args = ch_args =
grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_GZIP); grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_GZIP);
GPR_ASSERT(ch_args->num_args == 1); GPR_ASSERT(ch_args->num_args == 1);
GPR_ASSERT(strcmp(ch_args->args[0].key, GRPC_COMPRESSION_ALGORITHM_ARG) == 0); GPR_ASSERT(strcmp(ch_args->args[0].key,
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER); GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER);
grpc_channel_args_destroy(ch_args); grpc_channel_args_destroy(ch_args);

Loading…
Cancel
Save