-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathMessageInterface.php
More file actions
66 lines (59 loc) · 2.21 KB
/
Copy pathMessageInterface.php
File metadata and controls
66 lines (59 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
namespace Yiisoft\Queue\Message;
/**
* Represents a queue message with a type identifier, payload data, and metadata.
*
* @psalm-type MessagePayload = scalar|null|array<scalar|null|array>
* @psalm-type MessageMeta = array<string, scalar|null|array<scalar|null|array>>
*/
interface MessageInterface
{
/**
* Creates a new message instance from the given type and payload data.
*
* @param string $type Message type.
* @param bool|int|float|string|array|null $payload Message payload data. Must contain only `null`, scalars (`bool`,
* `int`, `float`, `string`), or arrays composed of the same types recursively.
*
* @psalm-param MessagePayload $payload
*
* @return static Instance of the called class with the given type and payload.
*/
public static function fromPayload(string $type, bool|int|float|string|array|null $payload): static;
/**
* Returns message type.
*
* @return string Message type.
*/
public function getType(): string;
/**
* Returns payload data.
*
* @return bool|int|float|string|array|null Payload data containing only `null`, scalars (`bool`, `int`, `float`,
* `string`), or arrays composed of the same types recursively.
*
* @psalm-return MessagePayload
*/
public function getPayload(): bool|int|float|string|array|null;
/**
* Returns message metadata: timings, attempt count, metrics, etc. Keys are always strings.
*
* @return array<string, bool|int|float|string|array|null> Metadata containing only `null`, scalars (`bool`, `int`,
* `float`, `string`), or arrays composed of the same types recursively.
*
* @psalm-return MessageMeta
*/
public function getMeta(): array;
/**
* Returns a new instance with the given message metadata.
*
* @param array<string, bool|int|float|string|array|null> $meta Metadata containing only `null`, scalars (`bool`,
* `int`, `float`, `string`), or arrays composed of the same types recursively.
*
* @return static New instance with the given metadata.
*
* @psalm-param MessageMeta $meta
*/
public function withMeta(array $meta): static;
}