Differential D10998 Diff 26420 src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery { | ||||
private function buildLimitClause(AphrontDatabaseConnection $conn_w, $limit) { | private function buildLimitClause(AphrontDatabaseConnection $conn_w, $limit) { | ||||
return qsprintf($conn_w, 'LIMIT %d', $limit); | return qsprintf($conn_w, 'LIMIT %d', $limit); | ||||
} | } | ||||
private function getLeaseOwnershipName() { | private function getLeaseOwnershipName() { | ||||
static $sequence = 0; | static $sequence = 0; | ||||
// TODO: If the host name is very long, this can overflow the 64-character | |||||
// column, so we pick just the first part of the host name. It might be | |||||
// useful to just use a random hash as the identifier instead and put the | |||||
// pid / time / host (which are somewhat useful diagnostically) elsewhere. | |||||
// Likely, we could store a daemon ID instead and use that to identify | |||||
// when and where code executed. See T6742. | |||||
$host = php_uname('n'); | |||||
$host = id(new PhutilUTF8StringTruncator()) | |||||
->setMaximumBytes(32) | |||||
->setTerminator('...') | |||||
->truncateString($host); | |||||
$parts = array( | $parts = array( | ||||
getmypid(), | getmypid(), | ||||
time(), | time(), | ||||
php_uname('n'), | $host, | ||||
btrahan: should we use PhutilStringTruncator here instead? I am not sure how fancy these characters… | |||||
++$sequence, | ++$sequence, | ||||
); | ); | ||||
return implode(':', $parts); | return implode(':', $parts); | ||||
} | } | ||||
} | } |
should we use PhutilStringTruncator here instead? I am not sure how fancy these characters could end up being.