Skip to content
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

Tracking HttpEndpoint creation #83

Open
bronsh opened this issue Jul 26, 2017 · 3 comments
Open

Tracking HttpEndpoint creation #83

bronsh opened this issue Jul 26, 2017 · 3 comments

Comments

@bronsh
Copy link
Contributor

bronsh commented Jul 26, 2017

Hi
I would like to add the ability of tracking the creation of Http listener (after calling MetricsConfig.WithHttpEndpoint).
This will enable me to wait until endpoint is listening before proceeding with my process.

I would like to create a pull request, but I don't know what is the preferred way to do this.

I can think about 3 different options:

  1. MetricsConfig will expose a copy of its private httpEndpoints dictionary. This will enable external users to use this dictionary to track their listener's task.
  2. Add an overload to the method WithHttpEndpoint with an "out" parameter which returns the listener Task
  3. Add a non-chainable method (StartHttpEndpoint) which returns a Task (instead of returning "this")

Please advise which option I should go with, or if you have some better idea.
Thanks !

@bronsh
Copy link
Contributor Author

bronsh commented Aug 8, 2017

Hi
Please share your opinion about this issue
Thanks

@PaulParau
Copy link
Member

Hi,

I think a cleaner way would be to add a boolean parameter to the WithHttpEndpoint method (something like bool waitUntilStarted = false). If it is set to true, then the method will not return this until the endpoint task has finished; otherwise it will behave as it does now.

What do you think of this solution?

Also, I'm curios, what use-case do you have that requires you to wait until the endpoint is listening?

Thanks

@bronsh
Copy link
Contributor Author

bronsh commented Sep 7, 2017

I think returning a Task is a better option, because it lets you do other things while listener is starting, and still be able to track over the Task to know whether it succeeded in listening or not.

The use-case is an application which needs to fail if the http listening did not succeed, for example, if it doesn't have the permissions to listen on the specific port.
I want the user will know something went wrong. I don't want him to work with the application unless he fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants