Skip to content

Commit

Permalink
sketching minimal stack configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Mar 31, 2017
1 parent 9c54a0c commit f2e609b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/grpc/impl/codegen/grpc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ typedef struct {
#define GRPC_ARG_ENABLE_CENSUS "grpc.census"
/** If non-zero, enable load reporting. */
#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting"
/** Request that optional features default to off (regardless of what they
usually default to) - to enable tight control over what gets enabled */
#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack"
/** Maximum number of concurrent incoming streams to allow on a http2
connection. Int valued. */
#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams"
Expand Down
2 changes: 1 addition & 1 deletion src/core/ext/census/grpc_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static bool is_census_enabled(const grpc_channel_args *a) {
return a->args[i].value.integer != 0 && census_enabled();
}
}
return census_enabled();
return census_enabled() && !grpc_channel_args_want_minimal_stack(a);
}

static bool maybe_add_census_filter(grpc_exec_ctx *exec_ctx,
Expand Down
7 changes: 7 additions & 0 deletions src/core/lib/channel/channel_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,10 @@ int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options) {
}
return arg->value.integer;
}

bool grpc_channel_args_want_minimal_stack(const grpc_channel_args *args) {
const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_MINIMAL_STACK);
if (arg == NULL) return false;
if (arg->type == GRPC_ARG_INTEGER && arg->value.integer == 0) return false;
return true;
}
2 changes: 2 additions & 0 deletions src/core/lib/channel/channel_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ grpc_channel_args *grpc_channel_args_set_socket_mutator(
const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args,
const char *name);

bool grpc_channel_args_want_minimal_stack(const grpc_channel_args *args);

typedef struct grpc_integer_options {
int default_value; // Return this if value is outside of expected bounds.
int min_value;
Expand Down
18 changes: 17 additions & 1 deletion src/core/lib/surface/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ static bool maybe_add_http_filter(grpc_exec_ctx *exec_ctx,
return true;
}

typedef struct {
const grpc_channel_filter *filter;
const char *controlling_channel_arg;
bool default_on;
} maybe_prepend_filter_args;

static const maybe_prepend_filter_args message_size_args = {
&grpc_message_size_filter, NULL, true};

static bool maybe_prepend_filter(grpc_exec_ctx *exec_ctx,
grpc_channel_stack_builder *builder,
void *arg) {
return grpc_channel_stack_builder_prepend_filter(
builder, (const grpc_channel_filter *)arg, NULL, NULL);
}

static void register_builtin_channel_init() {
grpc_channel_init_register_stage(
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
Expand All @@ -119,7 +135,7 @@ static void register_builtin_channel_init() {
(void *)&grpc_max_age_filter);
grpc_channel_init_register_stage(
GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
prepend_filter, (void *)&grpc_message_size_filter);
maybe_prepend_filter, (void *)&message_size_args);
grpc_channel_init_register_stage(
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
prepend_filter, (void *)&grpc_message_size_filter);
Expand Down

0 comments on commit f2e609b

Please sign in to comment.