-
Notifications
You must be signed in to change notification settings - Fork 0
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
Updated process name to get job that horizon is processing #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, just a minor comment. Too bad there's not a better way to get the name but this will be much nicer than the current setup 🚀
} elseif (is_array($arg) && array_key_exists('commandName', $arg)) { | ||
$command_name_parts = explode('\\', $arg['commandName']); | ||
$name = array_pop($command_name_parts); | ||
break 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suuuper minor but what about?
$raw_command_name = $arg?->commandName ?? $arg['commandName'] ?? '';
$parts = explode('\\', $raw_command_name);
$name = array_pop($parts);
or we could get it all onto one line 😬:
if ($commandName = array_pop(explode('\\', $arg?->commandName ?? $arg['commandName'] ?? ''))) {
$name = $commandName;
break 2;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@solflare These are some neat ideas. Minor issues with them:
- Calling a property on an array will cause a warning (
Attempt to read property "commandName" on array
) array_pop
takes byRef so the second options (1-liners) will throw a warning.
This is part of why I set them up the way I did. I wasn't super happy with it being so verbose but didn't see an easy way to clean up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomschlick @solflare How about this:
if ($command_name = json_decode(json_encode($arg), true)['commandName'] ?? null) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling a property on an array will cause a warning
I thought of the same issue and did a test to check, and calling a property on an array with the null coalescing operator doesn't throw an error and properly allows the fallback
array_pop takes byRef so the second options (1-liners) will throw a warning.
Hmm that's a harder one, and it's surprising there isn't an array function for this that doesn't pass by reference
Either way the update makes sense but it means we're encoding/decoding for each line of the stack trace until (if) we come across the commandName
🤔 Not the biggest deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@solflare Nice catch with the null coalesce part, missed that in my check. We are only encoding/decoding for the class CallQueuedHandler
as that is the outer check, then we encode/decode each arg under that class. Should greatly reduce the number of calls.
Updated the getProcessName method to resolve horizon tasks to the job that it is processing.
That leads to this value
becoming this