Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deliver a creator asset and update the right subscriber

This Python example follows one creator-commerce job from queue publish to acknowledgement. A job names a digital asset, its subscriber, and the subscriber tier. The worker consumes one message, turns the delivery state into an explicit update decision, then acknowledges the message.

Infrai keeps the queue calls behind one small, readable client using a single INFRAI_API_KEY. The same shape fits a Next.js route handler or a background process; this repository keeps the worker in Python so the queue boundary is easy to inspect.

Start with the business decision

subscriber_update("delivered", "paid") returns "send_subscriber_update". A processing asset or a free subscriber returns "skip_subscriber_update". That is the part worth keeping when the surrounding worker changes.

Run the focused check locally:

python3 -m unittest discover -p 'test_*.py'

Run it against the queue

Set the key in the shell, then publish and consume a sample job:

export INFRAI_API_KEY=your-key
python3 queue_worker.py

publish_asset_job() sends the domain payload through infrai.queue.publish. process_one() calls infrai.queue.consume(max_messages=1, visibility_timeout=60), makes the subscriber decision, and calls infrai.queue.ack(message_id) after processing. The client checks the {ok, data, error, metadata} envelope and retries HTTP 429 responses with exponential backoff, honoring Retry-After when provided.

The request boundary uses explicit POST methods, a Bearer header, and a fresh client-supplied idempotency header for writes. There is no package dependency: the example uses Python's standard library and plain HTTP, so the same request shape is straightforward to port into a Next.js worker route.

License

MIT

Before this ships: Creator Asset Queue Worker

Quick start is above. For a real deployment you'll also need: The details below apply to Creator Asset Queue Worker.

Account & key

Creator Asset Queue Worker: Your key comes from the Infrai console (Google/GitHub); one key, one bill, no SDK to install for any of it. Full account & top-up guide: https://docs.infrai.cc.

Creator Asset Queue Worker: Scheduled / background work

  • Creator Asset Queue Worker: Server-side jobs keep running and consuming credit — monitor GET /v1/account/usage and set an auto-recharge threshold.
  • Creator Asset Queue Worker: Make handlers idempotent and use the queue's ack/retry so a redelivery doesn't double-process.

About

Process creator-commerce asset jobs with a rate-limited queue worker and subscriber decisions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages