Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Queue\Registry;
16
17/**
18 * Registry interface
19 *
20 * A keyed store of WorkerRecords. Each worker writes only its own record,
21 * so implementations need no locking, lease or atomic-claim protocol -
22 * this is deliberately a much simpler contract than AdapterInterface.
23 *
24 * @category   Pop
25 * @package    Pop\Queue
26 * @author     Nick Sagona, III <nick@popphp.org>
27 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
28 * @license    https://www.popphp.org/license     New BSD License
29 * @version    3.0.0
30 */
31interface RegistryInterface
32{
33
34    /**
35     * Store a record, replacing any existing record with the same ID
36     *
37     * @param  WorkerRecord $record
38     * @return void
39     */
40    public function write(WorkerRecord $record): void;
41
42    /**
43     * Fetch a record by ID, or null if it isn't there
44     *
45     * @param  string $id
46     * @return ?WorkerRecord
47     */
48    public function read(string $id): ?WorkerRecord;
49
50    /**
51     * Fetch every stored record, keyed by worker ID
52     *
53     * @return array
54     */
55    public function all(): array;
56
57    /**
58     * Remove a record. A no-op if the ID isn't there.
59     *
60     * @param  string $id
61     * @return void
62     */
63    public function delete(string $id): void;
64
65    /**
66     * Remove every record whose heartbeat is older than the given number of
67     * seconds, returning how many were removed
68     *
69     * @param  int $olderThanSeconds
70     * @return int
71     */
72    public function prune(int $olderThanSeconds): int;
73
74}