aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/client_config
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ext/client_config')
-rw-r--r--src/core/ext/client_config/client_channel.c2
-rw-r--r--src/core/ext/client_config/lb_policy.c5
-rw-r--r--src/core/ext/client_config/lb_policy.h20
-rw-r--r--src/core/ext/client_config/lb_policy_factory.h25
4 files changed, 34 insertions, 18 deletions
diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c
index 8f1c821ebb..58ef629be0 100644
--- a/src/core/ext/client_config/client_channel.c
+++ b/src/core/ext/client_config/client_channel.c
@@ -572,7 +572,7 @@ static bool pick_subchannel(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
initial_metadata_flags,
&calld->lb_token_mdelem};
r = grpc_lb_policy_pick(exec_ctx, lb_policy, &inputs, connected_subchannel,
- on_ready);
+ NULL, on_ready);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "pick_subchannel");
GPR_TIMER_END("pick_subchannel", 0);
return r;
diff --git a/src/core/ext/client_config/lb_policy.c b/src/core/ext/client_config/lb_policy.c
index 71170f5655..903563ef6b 100644
--- a/src/core/ext/client_config/lb_policy.c
+++ b/src/core/ext/client_config/lb_policy.c
@@ -101,9 +101,10 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
+ grpc_connected_subchannel **target, void **user_data,
grpc_closure *on_complete) {
- return policy->vtable->pick(exec_ctx, policy, pick_args, target, on_complete);
+ return policy->vtable->pick(exec_ctx, policy, pick_args, target, user_data,
+ on_complete);
}
void grpc_lb_policy_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
diff --git a/src/core/ext/client_config/lb_policy.h b/src/core/ext/client_config/lb_policy.h
index 6f133a2948..734b3bff97 100644
--- a/src/core/ext/client_config/lb_policy.h
+++ b/src/core/ext/client_config/lb_policy.h
@@ -72,7 +72,8 @@ struct grpc_lb_policy_vtable {
/** \see grpc_lb_policy_pick */
int (*pick)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target, grpc_closure *on_complete);
+ grpc_connected_subchannel **target, void **user_data,
+ grpc_closure *on_complete);
/** \see grpc_lb_policy_cancel_pick */
void (*cancel_pick)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
@@ -138,14 +139,19 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
const grpc_lb_policy_vtable *vtable);
/** Find an appropriate target for this call, based on \a pick_args.
- Upon completion \a on_complete will be called, with \a *target set to an
- appropriate connected subchannel if the pick was successful or NULL
- otherwise.
- Picking can be asynchronous. Any IO should be done under \a
- pick_args->pollent. */
+ Picking can be synchronous or asynchronous. In the synchronous case, when a
+ pick is readily available, it'll be returned in \a target and a non-zero
+ value will be returned.
+ In the asynchronous case, zero is returned and \a on_complete will be called
+ once \a target and \a user_data have been set. Any IO should be done under
+ \a
+ pick_args->pollent.
+ The opaque \a user_data output argument corresponds to information that may
+ need be propagated from the LB policy. It may be NULL.
+ Errors are signaled by receiving a NULL \a *target. */
int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args,
- grpc_connected_subchannel **target,
+ grpc_connected_subchannel **target, void **user_data,
grpc_closure *on_complete);
/** Perform a connected subchannel ping (see \a grpc_connected_subchannel_ping)
diff --git a/src/core/ext/client_config/lb_policy_factory.h b/src/core/ext/client_config/lb_policy_factory.h
index 2125eaba70..e1d67633b4 100644
--- a/src/core/ext/client_config/lb_policy_factory.h
+++ b/src/core/ext/client_config/lb_policy_factory.h
@@ -47,16 +47,25 @@ struct grpc_lb_policy_factory {
const grpc_lb_policy_factory_vtable *vtable;
};
-typedef struct grpc_lb_policy_address_token {
- uint8_t *token;
- size_t token_size;
-} grpc_lb_policy_address_token;
+/** A resolved address alongside any LB related information associated with it.
+ * \a user_data, if not \a NULL, is opaque and meant to be consumed by the gRPC
+ * LB policy. Anywhere else, refer to the functions in \a
+ * grpc_lb_policy_user_data_vtable to operate with it */
+typedef struct grpc_lb_address {
+ grpc_resolved_address *resolved_address;
+ void *user_data;
+} grpc_lb_address;
+
+/** Functions acting upon the opaque \a grpc_lb_address.user_data */
+typedef struct grpc_lb_policy_user_data_vtable {
+ void *(*copy)(void *);
+ void (*destroy)(void *);
+} grpc_lb_policy_user_data_vtable;
typedef struct grpc_lb_policy_args {
- grpc_resolved_addresses *addresses;
- /* If not NULL, array of load balancing tokens associated with \a addresses,
- * on a 1:1 correspondence. Some indices may be NULL for missing tokens. */
- grpc_lb_policy_address_token *tokens;
+ grpc_lb_address *lb_addresses;
+ size_t num_addresses;
+ grpc_lb_policy_user_data_vtable user_data_vtable;
grpc_client_channel_factory *client_channel_factory;
} grpc_lb_policy_args;