Skip to main content

Firestore MQ python library

Project description

Firestore MQ Python Libary

Install

python3 setup.py install

OR

pip3 install firestoreMQ

Note that watching the queue requires an index, please run examples/worker.py to create the index

Examples

See examples/ for example scripts

Add a new task

import firestoreMQ
from firebase_admin import firestore

db = firestore.client() # TODO requires project initalisation

queue = "process_images"
data = {
  "image_path": "/path/to/images.png"
}
ttl = 3600 # seconds (optional)
priority = 0 # Higher priroty is higher number  (optional)

task = firestoreMQ.Task(queue, data, ttl=ttl, priority=priority)
task.create(db)

Process tasks

import firestoreMQ
import time
from firebase_admin import firestore

db = firestore.client() # TODO requires project initalisation

worker_id = "worker_1" # Unique worker ID (NOTE one per worker instance)
queue = "process_images"

while True:
  task = firestoreMQ.next_task(db, queue, worker_id) # Blocking call for next task

  if 'image_path' in task.data:
    print(task.data['image_path'])
    time.sleep(1)
    task.complete(db)
  else:
    print('[Task %s] Invalid task data - No "image_path"' % task.id)
    task.error(db)

Release

  • Bump version number
  • python3 setup.py sdist
  • twine upload dist/firestoreMQ-<VERSION>.tar.gz

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

firestoreMQ-1.0.4.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file firestoreMQ-1.0.4.tar.gz.

File metadata

  • Download URL: firestoreMQ-1.0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.4

File hashes

Hashes for firestoreMQ-1.0.4.tar.gz
Algorithm Hash digest
SHA256 727cfa944188a546545177ecc735885b37ab2df3715b663996330dfcfe5dcffa
MD5 a18e3ec4363a224c39b75313697c3a42
BLAKE2b-256 bbb32725d724b5994e21331a2f7d5c3a5be411922405692e586af1ba25cd0815

See more details on using hashes here.

Supported by

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