AccountOwnerLookup
final class AccountOwnerLookup (View source)
Finds the Poweradmin user a PowerDNS account value names, for zones that arrive without an owner (an autoprimary sets the account from its own configuration).
Methods
A lookup when dns.adopt_zone_owner_from_account is on, null otherwise.
The users these accounts name who have a zone limit, for lockAdopters() once the caller's transaction is open. Resets the per-run counts. Read before the transaction, so on MySQL the lock is taken before the snapshot the counts read from.
Locks the adopting users' rows in the open transaction, so a grant to the same user waits for the adoption and counts what it added.
Gives one zone to the user through $write, deciding under the user's lock like any other grant. Null when the user is at the limit and nothing was written.
The user a zone with this account should go to: userIdFor(), unless that user has no zones left under their limit, in which case the zone stays ownerless.
Zones adopterFor() left ownerless because their user was at the zone limit.
The id of the user whose username is exactly $account, or null when none is.
Details
__construct(PDO $db, ZoneOwnershipLimit|null $limits = null)
No description
static AccountOwnerLookup|null
forConfig(PDO $db, ConfigurationInterface $config)
A lookup when dns.adopt_zone_owner_from_account is on, null otherwise.
array
limitedAdopters(array $accounts)
The users these accounts name who have a zone limit, for lockAdopters() once the caller's transaction is open. Resets the per-run counts. Read before the transaction, so on MySQL the lock is taken before the snapshot the counts read from.
void
lockAdopters(array $userIds)
Locks the adopting users' rows in the open transaction, so a grant to the same user waits for the adoption and counts what it added.
bool|null
assignWithinLimit(int $userId, callable $write, int|null $zoneId = null)
Gives one zone to the user through $write, deciding under the user's lock like any other grant. Null when the user is at the limit and nothing was written.
int|null
adopterFor(string $account)
The user a zone with this account should go to: userIdFor(), unless that user has no zones left under their limit, in which case the zone stays ownerless.
Each call takes one zone from the user's remaining count.
int
heldBack()
Zones adopterFor() left ownerless because their user was at the zone limit.
int|null
userIdFor(string $account)
The id of the user whose username is exactly $account, or null when none is.