New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for service configs to c-ares resolver. #11954
Conversation
|
|
} | ||
grpc_json *service_config_json = NULL; | ||
for (grpc_json *field = choice->child; field != NULL; field = field->next) { | ||
// Check client language, if specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still use C style comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++-style comments are fine. They're legal in C99.
grpc_lb_addresses_create_channel_arg(r->lb_addresses); | ||
grpc_service_config *service_config = NULL; | ||
if (r->service_config_json != NULL) { | ||
char* service_config_string = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to free service_config_string
after grpc_channel_args_copy_and_add_and_remove()
is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed.
This looks great! Please also update the tests that are using |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update grpc_ares_wrapper_fallback.c.
} | ||
// Check client hostname, if specified. | ||
if (strcmp(field->key, "clientHostname") == 0) { | ||
char hostname[HOST_NAME_MAX]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we don't have HOST_NAME_MAX on mac. It's recommended by posix, but not required to be defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, was already working on that.
Done.
@nicolasnoble, please take a look at b826aa7 and let me know if I'm handling the portability issues the right way. Thanks! |
|
1 similar comment
|
|
|
||
#include "src/core/lib/iomgr/port.h" | ||
|
||
#if !defined(GRPC_POSIX_HOST_NAME_MAX) && !defined(GRPC_POSIX_SYSCONF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only small maintainability problem I see here potentially is if there's yet a new version of grpc_gethostname that gets added, this logic here is disjointed from adding a new entry (which resides in port.h).
Our main way to handle this is to add for instance GRPC_GETHOSTNAME_FALLBACK
in port.h close to the other checks where people would need to add their new implementation anyway, for example where you check for duplicated #defines
, you can also add the fallback definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
|
|
e85b1bd
to
f9bf428
Compare
This implements the functionality described in gRFC A2:
https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md
This also fixes a bug in the code from #10706, which broke the ability to actually specify an alternate DNS server.
I've done some basic manual testing of this, but there are no automated tests yet. In order to do that, I think we'll need to figure out how to run a DNS server in the automated test framework.