Code Monkey home page Code Monkey logo

Comments (8)

jterry75 avatar jterry75 commented on May 20, 2024 1
  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!

from docker.dotnet.

jterry75 avatar jterry75 commented on May 20, 2024 1

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

from docker.dotnet.

jterry75 avatar jterry75 commented on May 20, 2024

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.

from docker.dotnet.

jterry75 avatar jterry75 commented on May 20, 2024

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.

from docker.dotnet.

galvesribeiro avatar galvesribeiro commented on May 20, 2024

@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

from docker.dotnet.

galvesribeiro avatar galvesribeiro commented on May 20, 2024

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

from docker.dotnet.

galvesribeiro avatar galvesribeiro commented on May 20, 2024

@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! :)

from docker.dotnet.

galvesribeiro avatar galvesribeiro commented on May 20, 2024

Thanks @jterry75 let me what else todo :)

from docker.dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.