Giter Site home page Giter Site logo

qwebapi's Issues

Allow asynchronous handling of HTTP requests

Current implementation is synchronous. HTTP spec allows for async handling via status code 202 (https://tools.ietf.org/html/rfc7231#section-6.3.3)

This should be implemented something like follows:

  1. Request comes in to function that is "registered" as asynchronous (when defining API)
  2. Request is added to a queue table which will track details of (at least)
    • job ID
    • function & args
    • status (waiting, in progress, done)
  3. 202 response sent to initial request with Location header for queued resource e.g.
HTTP/1.1 202 Accepted
Location: /queue/12345
  1. Client can query /queue/12345 for updated status on job
  2. A some time after request has been added to queue, it will be processed & status updated to done
  3. When client queries /queue/12345 for completed job, response will be status 303 See Other (https://tools.ietf.org/html/rfc7231#section-6.4.4) with location of finished response e.g.
HTTP/1.1 303 See Other
Location: /thing/97865
  1. Client can query new location & get response for their original query

To allow API process to remain responsive to intermediate requests to /queue etc., processing should likely be done by another process, connecting via IPC & querying the queue table to get a job to do. However, this is considered beyond the scope of this module. Within webapi, we will provide the functionality to build the queue & send status updates to incoming queries to /queue.

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.