Reputation: 6276
In my app a user can upload several photographs at once.
Once these are received by the server the following happens:
Although everything works fine, there is no guarantee that the Gearman worker has completed by the time the database has updated. Meaning that a user may potentially get broken image links if they access a page which queries the database for those images.
Therefore I need to do one of the following:
For obvious reasons solution number 1 makes the most sense although of course that will have the drawback of potentially causing a delay between the user uploading the images and he/she actually being able to view them within the application.
Therefore this is really 2-3 questions in one:
If I do indeed go with solution 1 I need to be able to access the public functions for my main Applications database class and memcached class as well as the class of the function which called the Gearman worker itself, all from within the Gearman worker.
For example, in my main app to perform a MySQL PDO database query I use $query = new Query($sql);
then bind the values and execute it etc. And at the top of that file I have use \App\Query
so that I have access to those public functions. In other instances I would be accessing a function from within another function but in the same class using self::functionToPerform();
The Gearman workers scripts are external to my actual App so how would I go about accessing these functions from within the worker?
I know this is a lot to ask from one question and I hope I have articulated it well enough. Any help really would be appreciated.
Upvotes: 0
Views: 236
Reputation: 239
How important is real-time upload/update images? Because if time for process images is ~10 sec., user can see notification about this. And as soon as images ready web-page will be updated.
I think workers for images processing must do just this job. You can create workers for DB updates. It's will be two types of workers which can communicate with a message queue (like a RabbitMQ).
And upload process will be looks like this:
Ofcourse, if I right understand a problem...
Upvotes: 1