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

__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.

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.

Details

__construct(PDO $db, ZoneOwnershipLimit|null $limits = null)

No description

Parameters

PDO $db
ZoneOwnershipLimit|null $limits

Zone limits adoption respects; null adopts without limit

static AccountOwnerLookup|null forConfig(PDO $db, ConfigurationInterface $config)

A lookup when dns.adopt_zone_owner_from_account is on, null otherwise.

Parameters

PDO $db
ConfigurationInterface $config

Return Value

AccountOwnerLookup|null

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.

Parameters

array $accounts

Return Value

array

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.

Parameters

array $userIds

From limitedAdopters()

Return Value

void

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.

Parameters

int $userId
callable $write
int|null $zoneId

Return Value

bool|null

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.

Parameters

string $account

Return Value

int|null

int heldBack()

Zones adopterFor() left ownerless because their user was at the zone limit.

Return Value

int

int|null userIdFor(string $account)

The id of the user whose username is exactly $account, or null when none is.

Parameters

string $account

Return Value

int|null