Skip to content

examples: Allow passing target and simplify lifecycle#6630

Merged
ejona86 merged 1 commit intogrpc:masterfrom
ejona86:hello-enhance
Jan 23, 2020
Merged

examples: Allow passing target and simplify lifecycle#6630
ejona86 merged 1 commit intogrpc:masterfrom
ejona86:hello-enhance

Conversation

@ejona86
Copy link
Copy Markdown
Member

@ejona86 ejona86 commented Jan 22, 2020

The target can be provided on the command line to avoid needing to recompile
the example just to change where the server is located. We use a target instead
of addresses as that is the approach we have wanted to encourage for a while
since it allows choosing alternative name resolvers.

We typically encourage injecting Channels, not ManagedChannels, which has the
added benefit of simplifying the example. Less indirection makes for a better
example.

Swapping to target string could be done to examples-tls and examples-gauth as
well, but it would be much more invasive to the tls example and the gauth
example would need proper testing after the change.


These are things that I've wanted for a while, but now the target change is
necessary for the xds example and the rest sort of falls out of that.

The target can be provided on the command line to avoid needing to recompile
the example just to change where the server is located. We use a target instead
of addresses as that is the approach we have wanted to encourage for a while
since it allows choosing alternative name resolvers.

We typically encourage injecting Channels, not ManagedChannels, which has the
added benefit of simplifying the example. Less indirection makes for a better
example.

Swapping to target string could be done to examples-tls and examples-gauth as
well, but it would be much more invasive to the tls example and the gauth
example would need proper testing after the change.
@ejona86
Copy link
Copy Markdown
Member Author

ejona86 commented Jan 22, 2020

CC @donnadionne, @menghanl, this is a general cleanup of the helloworld example, but it does add more argument parsing. See the README added in #6631 to see how this will look to users in Java. C++'s plan of just adding a flag to set the target string sounds fine. Go may need to copy the main.go from the helloworld example, since it can't as easily do the trick I did to reuse the main() function.

@sanjaypujare
Copy link
Copy Markdown
Contributor

For the example to work with "xds:///..." (or "xds-experimental:///..." currently) target string the dependencies will need to include grpc-xds?

@ejona86
Copy link
Copy Markdown
Member Author

ejona86 commented Jan 22, 2020

@sanjaypujare, yes. See #6631

@dapengzhang0
Copy link
Copy Markdown
Contributor

Seems the README.md must be changed.

@ejona86
Copy link
Copy Markdown
Member Author

ejona86 commented Jan 22, 2020

@dapengzhang0, why must the readme be changed?

@dapengzhang0
Copy link
Copy Markdown
Contributor

Never mind, I though the hostname and port are present in the command line arguments in README, they are not.

@ejona86
Copy link
Copy Markdown
Member Author

ejona86 commented Jan 22, 2020

Note: After the next release this will require a smallish change to the tutorial since it has snippets of the routeguide that changed here. The quickstart is not impacted.

Copy link
Copy Markdown
Contributor

@dapengzhang0 dapengzhang0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ejona86 ejona86 merged commit 5b7f5b8 into grpc:master Jan 23, 2020
@ejona86 ejona86 deleted the hello-enhance branch January 23, 2020 21:13
@lock lock Bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants