-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc about cronjob locking is unclear #19
Comments
I suppose you've seen this part of the readme https://github.com/texthtml/php-lock#using-lock-for-crontabs ?
|
Yes. That you call it resource but use it as a identifier. That could just be called identifier then, no? |
It identifies a resources that the cron will operate on and should be locked on, eg: // invoices_aggregation_report.php
$lock = $factory->create('invoices-aggregation-report', 'process 1');
$lock->acquire();
foreach ($invoices as $invoice) {
$invoiceReport->add($invoice);
$invoice->saveToDatabase();
} a cron could also lock multiple resources in the same way: $invoicesReportLock = $factory->create('invoices-aggregation-report', 'process 1');
$invoicesReportLock->acquire();
$usersAccountLock = $factory->create('invoices-aggregation-report', 'process 1');
$usersAccountLock->acquire(); so each cron can declare which resources he wants to himself |
If "invoices-aggregation-report" is still running when the second cron comes around, it would fail then, yes? I mean, that all could be documented better. What the method takes as arguments and why, with more 'real life' examples like you posted above. |
yes it would fail, this part is in the readme:
and the second parameter is used for the logs, from the readme:
I probably won't add more documentation myself as I'm not actively working on this since it's mostly stable but feel free to open a Pull Request once you figure out a better way of explaining how it works (reading the phpspec tests & source code can help, it's a qucik read) |
Note: I have not used this project yet, this is just an observation of the README.md
I find it difficult to understand how this project can help you with locking cronjobs, therefore I'd like a more advanced cronjob example in the README file.
Ie. whats a "resource" (without looking at the src of that factory class)
The text was updated successfully, but these errors were encountered: