Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
981bfb0f
Commit
981bfb0f
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Plain Diff
Merge pull request #5933 from dgquintas/sockaddr_resolver_lb
added grpclb support to sockaddr resolver
parents
58b66f5a
b3b72497
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/lib/client_config/resolvers/sockaddr_resolver.c
+34
-5
34 additions, 5 deletions
src/core/lib/client_config/resolvers/sockaddr_resolver.c
with
34 additions
and
5 deletions
src/core/lib/client_config/resolvers/sockaddr_resolver.c
+
34
−
5
View file @
981bfb0f
...
@@ -267,17 +267,46 @@ static grpc_resolver *sockaddr_create(
...
@@ -267,17 +267,46 @@ static grpc_resolver *sockaddr_create(
r
->
lb_policy_name
=
NULL
;
r
->
lb_policy_name
=
NULL
;
if
(
0
!=
strcmp
(
args
->
uri
->
query
,
""
))
{
if
(
0
!=
strcmp
(
args
->
uri
->
query
,
""
))
{
gpr_slice
query_slice
;
gpr_slice
query_slice
;
gpr_slice_buffer
query_parts
;
gpr_slice_buffer
query_parts
;
/* the &-separated elements of the query */
gpr_slice_buffer
query_param_parts
;
/* the =-separated subelements */
query_slice
=
query_slice
=
gpr_slice_new
(
args
->
uri
->
query
,
strlen
(
args
->
uri
->
query
),
do_nothing
);
gpr_slice_new
(
args
->
uri
->
query
,
strlen
(
args
->
uri
->
query
),
do_nothing
);
gpr_slice_buffer_init
(
&
query_parts
);
gpr_slice_buffer_init
(
&
query_parts
);
gpr_slice_split
(
query_slice
,
"="
,
&
query_parts
);
gpr_slice_buffer_init
(
&
query_param_parts
);
GPR_ASSERT
(
query_parts
.
count
==
2
);
/* the query can contain "lb_policy=<policy>" and "lb_enabled=<1|0>" */
if
(
0
==
gpr_slice_str_cmp
(
query_parts
.
slices
[
0
],
"lb_policy"
))
{
r
->
lb_policy_name
=
gpr_dump_slice
(
query_parts
.
slices
[
1
],
GPR_DUMP_ASCII
);
bool
lb_enabled
;
gpr_slice_split
(
query_slice
,
"&"
,
&
query_parts
);
for
(
i
=
0
;
i
<
query_parts
.
count
;
i
++
)
{
gpr_slice_split
(
query_parts
.
slices
[
i
],
"="
,
&
query_param_parts
);
GPR_ASSERT
(
query_param_parts
.
count
==
2
);
if
(
0
==
gpr_slice_str_cmp
(
query_param_parts
.
slices
[
0
],
"lb_policy"
))
{
r
->
lb_policy_name
=
gpr_dump_slice
(
query_param_parts
.
slices
[
1
],
GPR_DUMP_ASCII
);
}
else
if
(
0
==
gpr_slice_str_cmp
(
query_param_parts
.
slices
[
0
],
"lb_enabled"
))
{
if
(
0
!=
gpr_slice_str_cmp
(
query_param_parts
.
slices
[
1
],
"0"
))
{
/* anything other than 0 is taken to be true */
lb_enabled
=
true
;
}
}
else
{
gpr_log
(
GPR_ERROR
,
"invalid query element value: '%s'"
,
query_parts
.
slices
[
0
]);
}
gpr_slice_buffer_reset_and_unref
(
&
query_param_parts
);
}
if
(
strcmp
(
"grpclb"
,
r
->
lb_policy_name
)
==
0
&&
!
lb_enabled
)
{
/* we want grpclb but the "resolved" addresses aren't LB enabled. Bail
* out, as this is meant mostly for tests. */
gpr_log
(
GPR_ERROR
,
"Requested 'grpclb' LB policy but resolved addresses don't "
"support load balancing."
);
abort
();
}
}
gpr_slice_buffer_destroy
(
&
query_parts
);
gpr_slice_buffer_destroy
(
&
query_parts
);
gpr_slice_buffer_destroy
(
&
query_param_parts
);
gpr_slice_unref
(
query_slice
);
gpr_slice_unref
(
query_slice
);
}
}
if
(
r
->
lb_policy_name
==
NULL
)
{
if
(
r
->
lb_policy_name
==
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment