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

Add cancellable attach. #432

Merged
merged 3 commits into from
Dec 21, 2015
Merged

Conversation

tomwilkie
Copy link
Contributor

Let me know what you think to the approach - I can extend it to exec also.

Fixes #161

@tomwilkie
Copy link
Contributor Author

I've extended this to StartExec now. What do you think? Would you prefer we pass in a channel the user can close instead?

@tomwilkie
Copy link
Contributor Author

@fsouza ping?

@fsouza
Copy link
Owner

fsouza commented Dec 14, 2015

Hi @tomwilkie, thank you very much for working on that! I'm planning to have a look at it later today or tomorrow, in the worst case. I've seen your comment on #161, the idea looks promising.

Sorry for taking that long to get back to you, and thank you again for contributing!

@tomwilkie
Copy link
Contributor Author

Not a problem! Let me know which way you prefer (returning an WaitCloser vs passing a channel) and I'll code it up.

@fsouza
Copy link
Owner

fsouza commented Dec 15, 2015

@tomwilkie I do prefer the WaitCloser approach, looking at the code at this moment!

return err
}
return cw.Wait()
}
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe AttachToContainer could just call AttachToContainerNonBlocking and then wait on the CloseWaiter? It would avoid code duplication.

The same applies for StartExec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good idea. Will do.

@fsouza
Copy link
Owner

fsouza commented Dec 15, 2015

I liked your implementation, I was wondering whether we could make CloseWaiter a parameter in AttachToContainerOptions (and StartExecOptions), along with a boolean flag for identifiying whether we want to block or not, but maybe just having another method is a better idea!

May I invoke others here? @peter-edge @cezarsa @andrewsmedina what do you all think? :-)

@tomwilkie
Copy link
Contributor Author

I liked your implementation,

Thanks!

I was wondering whether we could make CloseWaiter a parameter in AttachToContainerOptions (and StartExecOptions), along with a boolean flag for identifiying whether we want to block or not, but maybe just having another method is a better idea!

We could add it as a "out" parameter in the struct I guess - and that would solve the issue of naming the second copy of the function. Let me have a look and see how it feels - my initial thought is having the method in question modify the struct being passed in (and/or change its basic behaviour based on a bool) isn't particularly desirable.

@tomwilkie
Copy link
Contributor Author

May I invoke others here? @peter-edge @cezarsa @andrewsmedina what do you all think? :-)

Oh yes please!

if err != nil {
return err
}
if cw != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a scenario where both cw and err are nil?

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, just checked and there is hahaha

Sorry about that.

@fsouza
Copy link
Owner

fsouza commented Dec 21, 2015

I've spoken with @andrewsmedina and @cezarsa offline and we believe that it's good to merge. Thanks for contributing!

@fsouza fsouza merged commit 4dd2c21 into fsouza:master Dec 21, 2015
@tomwilkie
Copy link
Contributor Author

Thanks!

@pwaller
Copy link

pwaller commented Dec 21, 2015

Just saw this one fly by. A bit unfortunate it doesn't use x/net/context. Is it straightforward to build context-based cancellation on top of this?

@tomwilkie
Copy link
Contributor Author

@pwaller yes it should be relatively straight forward to hook this up to context-based cancellation.

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

Successfully merging this pull request may close these issues.

3 participants