PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.9.0 2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / vendor / symfony / var-dumper / Caster / RdKafkaCaster.php
kubio / vendor / symfony / var-dumper / Caster Last commit date
AmqpCaster.php 1 year ago ArgsStub.php 1 year ago Caster.php 1 year ago ClassStub.php 1 year ago ConstStub.php 4 years ago CutArrayStub.php 4 years ago CutStub.php 4 years ago DOMCaster.php 1 year ago DateCaster.php 1 year ago DoctrineCaster.php 1 year ago DsCaster.php 1 year ago DsPairStub.php 4 years ago EnumStub.php 4 years ago ExceptionCaster.php 1 year ago FiberCaster.php 1 year ago FrameStub.php 4 years ago GmpCaster.php 1 year ago ImagineCaster.php 4 years ago ImgStub.php 1 year ago IntlCaster.php 1 year ago LinkStub.php 1 year ago MemcachedCaster.php 1 year ago MysqliCaster.php 1 year ago PdoCaster.php 1 year ago PgSqlCaster.php 1 year ago ProxyManagerCaster.php 1 year ago RdKafkaCaster.php 1 year ago RedisCaster.php 1 year ago ReflectionCaster.php 1 year ago ResourceCaster.php 1 year ago SplCaster.php 1 year ago StubCaster.php 1 year ago SymfonyCaster.php 1 year ago TraceStub.php 1 year ago UuidCaster.php 4 years ago XmlReaderCaster.php 1 year ago XmlResourceCaster.php 1 year ago
RdKafkaCaster.php
187 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\VarDumper\Caster;
13
14 use RdKafka\Conf;
15 use RdKafka\Exception as RdKafkaException;
16 use RdKafka\KafkaConsumer;
17 use RdKafka\Message;
18 use RdKafka\Metadata\Broker as BrokerMetadata;
19 use RdKafka\Metadata\Collection as CollectionMetadata;
20 use RdKafka\Metadata\Partition as PartitionMetadata;
21 use RdKafka\Metadata\Topic as TopicMetadata;
22 use RdKafka\Topic;
23 use RdKafka\TopicConf;
24 use RdKafka\TopicPartition;
25 use Symfony\Component\VarDumper\Cloner\Stub;
26
27 /**
28 * Casts RdKafka related classes to array representation.
29 *
30 * @author Romain Neutron <imprec@gmail.com>
31 */
32 class RdKafkaCaster
33 {
34 public static function castKafkaConsumer(KafkaConsumer $c, array $a, Stub $stub, bool $isNested)
35 {
36 $prefix = Caster::PREFIX_VIRTUAL;
37
38 try {
39 $assignment = $c->getAssignment();
40 } catch (RdKafkaException $e) {
41 $assignment = [];
42 }
43
44 $a += [
45 $prefix.'subscription' => $c->getSubscription(),
46 $prefix.'assignment' => $assignment,
47 ];
48
49 $a += self::extractMetadata($c);
50
51 return $a;
52 }
53
54 public static function castTopic(Topic $c, array $a, Stub $stub, bool $isNested)
55 {
56 $prefix = Caster::PREFIX_VIRTUAL;
57
58 $a += [
59 $prefix.'name' => $c->getName(),
60 ];
61
62 return $a;
63 }
64
65 public static function castTopicPartition(TopicPartition $c, array $a)
66 {
67 $prefix = Caster::PREFIX_VIRTUAL;
68
69 $a += [
70 $prefix.'offset' => $c->getOffset(),
71 $prefix.'partition' => $c->getPartition(),
72 $prefix.'topic' => $c->getTopic(),
73 ];
74
75 return $a;
76 }
77
78 public static function castMessage(Message $c, array $a, Stub $stub, bool $isNested)
79 {
80 $prefix = Caster::PREFIX_VIRTUAL;
81
82 $a += [
83 $prefix.'errstr' => $c->errstr(),
84 ];
85
86 return $a;
87 }
88
89 public static function castConf(Conf $c, array $a, Stub $stub, bool $isNested)
90 {
91 $prefix = Caster::PREFIX_VIRTUAL;
92
93 foreach ($c->dump() as $key => $value) {
94 $a[$prefix.$key] = $value;
95 }
96
97 return $a;
98 }
99
100 public static function castTopicConf(TopicConf $c, array $a, Stub $stub, bool $isNested)
101 {
102 $prefix = Caster::PREFIX_VIRTUAL;
103
104 foreach ($c->dump() as $key => $value) {
105 $a[$prefix.$key] = $value;
106 }
107
108 return $a;
109 }
110
111 public static function castRdKafka(\RdKafka $c, array $a, Stub $stub, bool $isNested)
112 {
113 $prefix = Caster::PREFIX_VIRTUAL;
114
115 $a += [
116 $prefix.'out_q_len' => $c->getOutQLen(),
117 ];
118
119 $a += self::extractMetadata($c);
120
121 return $a;
122 }
123
124 public static function castCollectionMetadata(CollectionMetadata $c, array $a, Stub $stub, bool $isNested)
125 {
126 $a += iterator_to_array($c);
127
128 return $a;
129 }
130
131 public static function castTopicMetadata(TopicMetadata $c, array $a, Stub $stub, bool $isNested)
132 {
133 $prefix = Caster::PREFIX_VIRTUAL;
134
135 $a += [
136 $prefix.'name' => $c->getTopic(),
137 $prefix.'partitions' => $c->getPartitions(),
138 ];
139
140 return $a;
141 }
142
143 public static function castPartitionMetadata(PartitionMetadata $c, array $a, Stub $stub, bool $isNested)
144 {
145 $prefix = Caster::PREFIX_VIRTUAL;
146
147 $a += [
148 $prefix.'id' => $c->getId(),
149 $prefix.'err' => $c->getErr(),
150 $prefix.'leader' => $c->getLeader(),
151 ];
152
153 return $a;
154 }
155
156 public static function castBrokerMetadata(BrokerMetadata $c, array $a, Stub $stub, bool $isNested)
157 {
158 $prefix = Caster::PREFIX_VIRTUAL;
159
160 $a += [
161 $prefix.'id' => $c->getId(),
162 $prefix.'host' => $c->getHost(),
163 $prefix.'port' => $c->getPort(),
164 ];
165
166 return $a;
167 }
168
169 private static function extractMetadata($c)
170 {
171 $prefix = Caster::PREFIX_VIRTUAL;
172
173 try {
174 $m = $c->getMetadata(true, null, 500);
175 } catch (RdKafkaException $e) {
176 return [];
177 }
178
179 return [
180 $prefix.'orig_broker_id' => $m->getOrigBrokerId(),
181 $prefix.'orig_broker_name' => $m->getOrigBrokerName(),
182 $prefix.'brokers' => $m->getBrokers(),
183 $prefix.'topics' => $m->getTopics(),
184 ];
185 }
186 }
187