8000 Feature: asynchronous processing · Issue #76 · cloudcreativity/laravel-json-api · GitHub
[go: up one dir, main page]

Skip to content
Feature: asynchronous processing #76
Closed
@pascal08

Description

@pascal08

I have a JsonApi endpoint /prices. When I submit a post request to this endpoint I would like to dispatch a job that is going to grab prices from a couple of external sources. I would like to return a response immediately that contains a reference to the dispatched job, like this: http://jsonapi.org/recommendations/#asynchronous-processing

This would be a high-level description of how I would solve this:

  1. Create a JsonApi endpoint for fetching the job resources.
  2. Override the create method on PricesController with some code to dispatch the price fetching job
  3. Return a response containing a reference url to the job resource.

This would return something like this:

HTTP/1.1 202 Accepted
Content-Type: application/vnd.api+json
Content-Location: https://example.com/jobs/1234

{
  "data": {
    "type": "jobs",
    "id": "1234",
    "attributes": {
      "status": "Pending request, waiting other process"
    },
    "links": {
      "self": "/jobs/1234"
    }
  }
}

When the job is processed this endpoint returns:

HTTP/1.1 303 See other
Content-Type: application/vnd.api+json
Location: https://example.com/prices/4321

I think it would be nice if this package supports this recommendation. What do you think? I'd be happy to help integrating this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0