Giter Site home page Giter Site logo

Support for async interface about katipo HOT 5 OPEN

puzza007 avatar puzza007 commented on May 20, 2024
Support for async interface

from katipo.

Comments (5)

silviucpp avatar silviucpp commented on May 20, 2024 1

@puzza007 I honestly inspired myself from https://github.com/lpgauth/buoy . Difference is that in buoy you get on single message at the end of the response with the response. In hackney you get multiple messages progressively like: when you get the headers, when you get the body and one at the final... This makes most of the use cases complicated because you have to aggregate yourself everything and when the done response comes you know you have the response.

from katipo.

puzza007 avatar puzza007 commented on May 20, 2024

It's certainly possible. At the moment it uses https://erlang.org/doc/man/gen_server.html#reply-2 to make synchronous responses. Do you have an existing asynch API in mind?

from katipo.

silviucpp avatar silviucpp commented on May 20, 2024

I'm thinking that inside the request options to add:

  • async = true| false (default is false to work as it is now)
  • reply_to = any pid (default to self())

And when async = true the katipo:req to return {ok, ResponseReference::ref()}

Once the response is available the process indicated in reply_to to receive a message like:

{katipo_resp, ResponseReference, Response} where ResponseReference to be the one you returned in the request and
Response to be the HTTP call response:

#{status := 200,
       headers := RespHeaders,
       cookiejar := CookieJar,
       body := RespBody}

or whatever katipo:req returns normally when using sync calls.

What do you think ?

Silviu

from katipo.

puzza007 avatar puzza007 commented on May 20, 2024

Cool so basically something like https://github.com/benoitc/hackney#get-a-response-asynchronously 👍

from katipo.

puzza007 avatar puzza007 commented on May 20, 2024

Cool. I've started a branch with some very early work. I haven't got it running yet.

from katipo.

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.