Reputation: 11
I have just completed my first API in Apigility. Right now it is basically a gateway to a database, storing and retrieving multi-page documents uploaded through an app.
Now I want to run some processing on the documents, e.g. process them through a 3rd party API or modify the image quality etc., and return them to the app users.
GET
request. I thought about running an asynchronous process and send a push notification to the app, once the processing is complete. But again, where in the could would I ideally implement such processing logic?I would be very happy to receive some architectural advice from someone who is more seasoned in developing APIs. Thank you.
Upvotes: 0
Views: 216
Reputation: 44326
You are able to use the zf-rest
resource events to connect listeners with your additional custom logic without polluting your resources.
These events are fired in the RestController
class (for example a post.create
event here on line 382).
When you use Apigility-Doctrine module you can also use the events triggered in the DoctrineResource
class (for example the DoctrineResourceEvent::EVENT_CREATE_POST
event here on line 361) to connect your listeners.
You can use a queueing service like ZendQueue
or something (a third party module) built on top of ZendQueue
for managing that. You can find different ZF2 queueing systems/modules using Google.
By injecting the queueing service into your listener you can simply push your jobs directly into your queue.
Upvotes: 1