Open judgedim opened 2 years ago
Hello, I thinking about that in the past and I'm not against it, out of curiosity what is your use case?
My use case for this is I need to run some jobs on multiple servers/containers. I have worker processes pulling from a Redis queue.
I second that. I have two use cases:
OK guys, would you consider sponsoring (financially) this feature?
Not really. :( But I have started to look into it yesterday. I will try to use existing id property of Event, which is now assigned randomly to be able to pass it through Scheduler->run (making sure that it is unique), list it in schedule:list and use it for schedule:run -t xxx. For the latter it will be required that assigned id will be non-numeric otherwise it will treat it as TaskNumber.
@jszczypk You can also create a PR :)
I will. :)
For my Crunz-ui repository I needed a unique identifier for each task and I used a system like this:
$TASKS_DIR = 'XXXXX' // -> represents the path of the folder where the tasks files are contained
$row = [];
$row["filename"] = $taskFile->getFilename();
$row["real_path"] = $taskFile->getRealPath();
$row["subdir"] = str_replace( array( $TASKS_DIR, $row["filename"]),'',$row["real_path"]);
$row["task_path"] = str_replace($TASKS_DIR, '', $row["real_path"]);
$row["event_id"] = $oEVENT->getId();
$row["event_launch_id"] = $task_counter;
$row["event_file_id"] = $event_file_id;
$row["task_description"] = $oEVENT->description;
$row["expression"] = $oEVENT->getExpression();
$row["event_unique_key"] = md5($row["task_path"] . $row["task_description"] . $row["expression"]);
This method is a bit rustic but it worked in my case.
The contraindication is that if the event changes the description or configuration of the execution moment or the path within the folder where the tasks are contained, the event changes its unique id.
However, it works better than the id obtained from the getId() function which essentially changes every time a new event is added.
If you have better suggestions, they would help me too.
@PabloKowalczyk, I would like to introduce, in the Event Class, a method to obtain a unique non-numeric identifier for the task that does not change even if new tasks are inserted.
I tested getId() method but the returned value changes every time new tasks are inserted.
I would like to use a similar method as shown before.
I would like to use the result of getExpression() method and the content of 'description' variable as parameters for calculating the unique key.
However, I need another parameter that allows me to uniquely identify the event (with these two parameters only I risk calculating the same ID for two tasks with the same description and the same launch date and time maybe in different subdir in tasks directory).
Do you think this could be a good idea? What do you think I can use as a parameter to better identify a task?
@lucatacconi I think it may work, feel free to open PR :)
Next step, after "stable ids", can be user-provided ids, but this needs more work.
Description
Currently we can run individual task only using dynamic numeric id
-t, --task=TASK Which task to run. Provide task number from schedule:list command.
Which does not guarantee that it does the same task every time.What do you think for introduce non-numeric identifier which can be used alongside with numeric id for run command in more predictable way?
Example
Usage:
Run
schedule:run --task=backup
List
crunz schedule:list