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

Tasks that return status streams should be replaced with calls to IProgress<StreamStatus> #108

Closed
swernli opened this issue Jul 28, 2016 · 8 comments
Assignees
Milestone

Comments

@swernli
Copy link
Collaborator

swernli commented Jul 28, 2016

Methods that return a Task<Stream> like PullImageAsync could instead return Task<IProgress<Stream>> to abstract away some of the details of how docker reports it's progress. This should simplify patterns for callers who want to report that progress.

@jterry75 Can expand on what we are looking for here.

@jterry75
Copy link
Contributor

jterry75 commented Aug 2, 2016

Instead of returning Task<Stream> we should return Task. Then add a parameter to the function that takes IProgress<PullStatus> progress. Each time that we receive the new "stream value" we deserialize it into the PullStatus and then Report() any waiter. The client looks like this:

var p = new Progress<Docker.DotNet.PullStatus>(status =>
{
// Do something with the status? Update a UI/PS/Service on the Sync Context of your choice.
});

await PullImageAsync(/*params*/, p);

PullStatus is just a moniker. If Docker always does the same status struct then we can just use that instead for all methods that return a Task<Stream> where <Stream> contains only data that is just status. IE: docker logs is not a candidate here because the logs are an actual value.

@jterry75 jterry75 added this to the v2.124.2 milestone Aug 4, 2016
@jterry75 jterry75 changed the title Task<Stream> should be replaced by a Task<IProgress<Stream>> Tasks that return status streams should be replaced with calls to IProgress<StreamStatus> Sep 1, 2016
@jterry75
Copy link
Contributor

jterry75 commented Sep 1, 2016

I updated the tile which was very misleading. My response above is what we actually want. Not to change the return type to return progress but rather pass in an IProgress of the appropriate type so we can handle the status reporting to waiters.

@galvesribeiro
Copy link
Member

galvesribeiro commented Jan 17, 2017

@jterry75 as mentioned on #143, Lets implement this issue.

I would like to align here the proper method signatures:

  1. For methods that are today returning Task<Stream> we should do as you mentioned here, correct?
  2. For methods that are long running monitoring, like the ones on MISC endpoint, which endlessly monitor events on the engine/swarm, I would suggest return an IObservable<T> where T is a structure with the general status update. That way, people don't need to await on that and instead can just subscribe. They can even use Rx to consume. As you may know, IObservable<T> is available on .Net so we don't need add any dependencies... What do you think?

When I got answer for those two I'll submit the PR.

Thanks

@jterry75
Copy link
Contributor

  1. Agreed, I think anything that returns Task other than the image downloads can be done this way.
  2. Correct that is the right pattern for Long Running Tasks, I would love to see that change!

@galvesribeiro
Copy link
Member

Perfect! Will do it tonight when get home. Thanks @jterry75

@galvesribeiro
Copy link
Member

@jterry75 it is done on #147.

I decided to not use IObservable<T> because it will be too big breaking change on the public APIs.

I think IProgress<T> is enough for that case. Specially that most of the time, the events are limited to an small number.

Please review when you can so I can move to the others. Thanks! Appreciate the support! :)

@jterry75
Copy link
Contributor

This has been merged. Self assigning to cleanup Push/PullImageAsync in the v1.13 branch given the inclusion of JSONMessage etc.

@jterry75 jterry75 self-assigned this Jan 19, 2017
@galvesribeiro
Copy link
Member

Thanks @jterry75 let me what else todo :)

jterry75 added a commit to jterry75/Docker.DotNet that referenced this issue Jan 19, 2017
Resolves dotnet#108.

Full implements the IProgress<Stream> changes for the v1.13 api change
using JSONMessage JSONProgress and JSONError
mdarocha pushed a commit to TrapTech/Docker.DotNet that referenced this issue Jul 11, 2022
Introduce extensible remote path quoting mechanism.
Fixes issues dotnet#256 and dotnet#108.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants