Skip to main content

Facebook-like implementation of batch requests

Project description

PyPI version Travis CI Coverage Status Code Health Python Versions Implementation

Quick start

examples:

curl -X POST \
  http://127.0.0.1:8000/batch/ \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{"batch": [
    {
        "method": "get",
        "relative_url": "/test/",
        "name": "yolo"
    },
    {
        "method": "post",
        "relative_url": "/test/?id={result=yolo:$.id}&ids={result=yolo:$.data.*.id}",
        "body": {"data": {"id": "{result=yolo:$.id}", "ids": "{result=yolo:$.data.*.id}"}, "test": "yolo"}
    },
    {
        "method": "post",
        "relative_url": "/test/",
        "body": "{\"data\": 42}",
        "omit_response_on_success": true
    },
    {
        "method": "options",
        "relative_url": "/test/"
    }
]
}'

using file uploading

curl -X POST \
  http://127.0.0.1:8000/batch/ \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'batch=[
    {
        "method": "get",
        "relative_url": "/test/",
        "name": "yolo"
    },
    {
        "method": "post",
        "relative_url": "/test/?id={result=yolo:$.id}&ids={result=yolo:$.data.*.id}",
        "body": {"data": "{result=yolo:$.data.*.id}", "test": "yolo"},
        "attached_files":{"file": "a.jpg"}
    },
    {
        "method": "post",
        "relative_url": "/test/",
        "body": "{\"data\": 42}",
        "omit_response_on_success": true,
        "attached_files":["a.jpg", "b.png"]
    },
    {
        "method": "options",
        "relative_url": "/test/"
    }
]' \
  -F b.png=@2476.png \
  -F a.jpg=@check_133.pdf

Future features:

  • add support for requests pipelining. use responses as arguments to next requests (done)

  • build graph based on requests dependencies & run simultaneously independent.

  • [STRIKEOUT:switchable atomic support. true - all fails if something wrong. else - fail only dependent (can be very hard to support on front-end side, but for now seems as good feature)] run all requests in single transaction. (done)

  • [STRIKEOUT:use native django. we don’t use complicated things that require drf for work. all can be done with “naked” django.] (since we validate requests with drf serializers, it’s better to leave as it is).

  • support files uploading (done)

Dependencies:

  • Django starting from 2.2

  • Django rest framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf-batch-requests-0.9.1.tar.gz (36.2 kB view details)

Uploaded Source

Built Distribution

drf_batch_requests-0.9.1-py3-none-any.whl (75.4 kB view details)

Uploaded Python 3

File details

Details for the file drf-batch-requests-0.9.1.tar.gz.

File metadata

  • Download URL: drf-batch-requests-0.9.1.tar.gz
  • Upload date:
  • Size: 36.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for drf-batch-requests-0.9.1.tar.gz
Algorithm Hash digest
SHA256 7b1451d6c017ae25167241c5dfb8a792fb19110ea504b07c0bd0869b18d6a346
MD5 5587ea2cacfb3222ad0b3b8ca1e865b3
BLAKE2b-256 4a38444c0a8d879a7f9a9451504aafd52a92767ae6110e5d022a46440f2ea236

See more details on using hashes here.

File details

Details for the file drf_batch_requests-0.9.1-py3-none-any.whl.

File metadata

File hashes

Hashes for drf_batch_requests-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd1c0fc9cbf9e3fecca56e2d86f14a119f81a92ec5e9901f79a1ad99942fec48
MD5 f1a209207d5bc131ca77ccc390e42523
BLAKE2b-256 17cd7458946055c226068f1c4cd55fb5eb4a937480d35ecf6aa4634ee5bd2ad7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page