GRPC Core  0.10.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lb_policy.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H
35 #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H
36 
38 
43 
44 typedef void (*grpc_lb_completion)(void *cb_arg, grpc_subchannel *subchannel,
45  grpc_status_code status, const char *errmsg);
46 
50 };
51 
53  void (*destroy)(grpc_lb_policy *policy);
54 
55  void (*shutdown)(grpc_lb_policy *policy);
56 
58  void (*pick)(grpc_lb_policy *policy, grpc_pollset *pollset,
59  grpc_metadata_batch *initial_metadata, grpc_subchannel **target,
60  grpc_iomgr_closure *on_complete);
61 
63  void (*exit_idle)(grpc_lb_policy *policy);
64 
67 
70 
75  grpc_iomgr_closure *closure);
76 };
77 
78 #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG
79 #define GRPC_LB_POLICY_REF(p, r) \
80  grpc_lb_policy_ref((p), __FILE__, __LINE__, (r))
81 #define GRPC_LB_POLICY_UNREF(p, r) \
82  grpc_lb_policy_unref((p), __FILE__, __LINE__, (r))
83 void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line,
84  const char *reason);
85 void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line,
86  const char *reason);
87 #else
88 #define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p))
89 #define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p))
92 #endif
93 
96  const grpc_lb_policy_vtable *vtable);
97 
100 
105 void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset,
106  grpc_metadata_batch *initial_metadata,
107  grpc_subchannel **target,
108  grpc_iomgr_closure *on_complete);
109 
111 
113 
116  grpc_iomgr_closure *closure);
117 
119  grpc_lb_policy *policy);
120 
121 #endif /* GRPC_INTERNAL_CORE_CONFIG_LB_POLICY_H */
const grpc_lb_policy_vtable * vtable
Definition: lb_policy.h:48
grpc_connectivity_state
Connectivity state of a channel.
Definition: grpc.h:139
Definition: sync_generic.h:49
void grpc_lb_policy_exit_idle(grpc_lb_policy *policy)
Definition: lb_policy.c:81
Definition: stream_op.h:87
grpc_connectivity_state grpc_lb_policy_check_connectivity(grpc_lb_policy *policy)
Definition: lb_policy.c:91
void(* pick)(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_metadata_batch *initial_metadata, grpc_subchannel **target, grpc_iomgr_closure *on_complete)
implement grpc_lb_policy_pick
Definition: lb_policy.h:58
void(* broadcast)(grpc_lb_policy *policy, grpc_transport_op *op)
broadcast a transport op to all subchannels
Definition: lb_policy.h:66
Definition: pollset_posix.h:48
Definition: subchannel.c:77
void(* grpc_lb_completion)(void *cb_arg, grpc_subchannel *subchannel, grpc_status_code status, const char *errmsg)
Definition: lb_policy.h:44
void grpc_lb_policy_broadcast(grpc_lb_policy *policy, grpc_transport_op *op)
Definition: lb_policy.c:77
Definition: lb_policy.h:52
void grpc_lb_policy_shutdown(grpc_lb_policy *policy)
Start shutting down (fail any pending picks)
Definition: lb_policy.c:66
void(* destroy)(grpc_lb_policy *policy)
Definition: lb_policy.h:53
A closure over a grpc_iomgr_cb_func.
Definition: iomgr.h:45
gpr_refcount refs
Definition: lb_policy.h:49
void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_metadata_batch *initial_metadata, grpc_subchannel **target, grpc_iomgr_closure *on_complete)
Given initial metadata in initial_metadata, find an appropriate target for this rpc, and 'return' it by calling on_complete after setting target.
Definition: lb_policy.c:70
void(* shutdown)(grpc_lb_policy *policy)
Definition: lb_policy.h:55
void grpc_lb_policy_ref(grpc_lb_policy *policy)
Definition: lb_policy.c:48
void(* notify_on_state_change)(grpc_lb_policy *policy, grpc_connectivity_state *state, grpc_iomgr_closure *closure)
call notify when the connectivity state of a channel changes from *state.
Definition: lb_policy.h:73
grpc_status_code
Definition: status.h:41
void grpc_lb_policy_unref(grpc_lb_policy *policy)
Definition: lb_policy.c:59
void(* exit_idle)(grpc_lb_policy *policy)
try to enter a READY connectivity state
Definition: lb_policy.h:63
void grpc_lb_policy_notify_on_state_change(grpc_lb_policy *policy, grpc_connectivity_state *state, grpc_iomgr_closure *closure)
Definition: lb_policy.c:85
void grpc_lb_policy_init(grpc_lb_policy *policy, const grpc_lb_policy_vtable *vtable)
called by concrete implementations to initialize the base struct
Definition: lb_policy.c:36
Definition: lb_policy.h:47
Transport op: a set of operations to perform on a transport as a whole.
Definition: transport.h:90
grpc_connectivity_state(* check_connectivity)(grpc_lb_policy *policy)
check the current connectivity of the lb_policy
Definition: lb_policy.h:69