-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Dont block on grpc if nothing is listeing on rkt api service port #1218
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
Conversation
@@ -37,6 +38,13 @@ var ( | |||
|
|||
func Client() (rktapi.PublicAPIClient, error) { | |||
once.Do(func() { | |||
_, err := net.Dial("tcp", "localhost:15441") |
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.
Use defaultRktAPIServiceAddr
here
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.
I think you should use DialTimeout
with a reasonable value
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 connection should be closed
Thanks for fixing this! |
@@ -38,17 +38,19 @@ var ( | |||
|
|||
func Client() (rktapi.PublicAPIClient, error) { | |||
once.Do(func() { | |||
_, err := net.Dial("tcp", "localhost:15441") | |||
conn, err := net.DialTimeout("tcp", defaultRktAPIServiceAddr, 2*time.Second) |
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.
Any reason you chose a different timeout from the one below? If not, can you create a timeout const to use in both places instead.
Looks like you need to run |
Attempts an initial connection to the rkt api service via the golang net api. Only try grpc if that succeeds.