cluster: Fix Cluster::publish() of Broker::Data

The broker serializer leverages the existing data_to_val() function.
During unserialization, if the destination type is any, the logic
simply wraps the broker::data value into a Broker::Data record.
Therefore, events with any parameters are currently exposed to
the Broker::Data type.

There is a bigger issue in that re-publishing such Broker::Data
instances would encode them as a normal record. Explicitly prevent
this by serializing the contained data value directly instead, similar
to what Broker already did when publishing a record.
This commit is contained in:
Arne Welzel 2024-12-12 11:25:31 +01:00
parent 271fc15041
commit d9a74cf32d
9 changed files with 379 additions and 4 deletions

View file

@ -0,0 +1,37 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
node_up, worker-1
sending pings, 0, count, 1
got pong, 1, with, 0, count (cluster publish), Broker::Data, [data=broker::data{1}]
got pong, 2, with, 0, count (cluster event ), Broker::Data, [data=broker::data{1}]
got pong, 3, with, 0, count (cluster publish), Broker::Data, [data=broker::data{1}]
got pong, 4, with, 0, count (cluster event ), Broker::Data, [data=broker::data{1}]
got pong, 5, with, 0, count (cluster publish), Broker::Data, [data=broker::data{1}]
got pong, 6, with, 0, count (cluster event ), Broker::Data, [data=broker::data{1}]
sending pings, 1, string, a string
got pong, 7, with, 1, string (cluster publish), Broker::Data, [data=broker::data{a string}]
got pong, 8, with, 1, string (cluster event ), Broker::Data, [data=broker::data{a string}]
got pong, 9, with, 1, string (cluster publish), Broker::Data, [data=broker::data{a string}]
got pong, 10, with, 1, string (cluster event ), Broker::Data, [data=broker::data{a string}]
got pong, 11, with, 1, string (cluster publish), Broker::Data, [data=broker::data{a string}]
got pong, 12, with, 1, string (cluster event ), Broker::Data, [data=broker::data{a string}]
sending pings, 2, port, 42/tcp
got pong, 13, with, 2, port (cluster publish), Broker::Data, [data=broker::data{42/tcp}]
got pong, 14, with, 2, port (cluster event ), Broker::Data, [data=broker::data{42/tcp}]
got pong, 15, with, 2, port (cluster publish), Broker::Data, [data=broker::data{42/tcp}]
got pong, 16, with, 2, port (cluster event ), Broker::Data, [data=broker::data{42/tcp}]
got pong, 17, with, 2, port (cluster publish), Broker::Data, [data=broker::data{42/tcp}]
got pong, 18, with, 2, port (cluster event ), Broker::Data, [data=broker::data{42/tcp}]
sending pings, 3, vector of count, [1, 2, 3]
got pong, 19, with, 3, vector of count (cluster publish), Broker::Data, [data=broker::data{(1, 2, 3)}]
got pong, 20, with, 3, vector of count (cluster event ), Broker::Data, [data=broker::data{(1, 2, 3)}]
got pong, 21, with, 3, vector of count (cluster publish), Broker::Data, [data=broker::data{(1, 2, 3)}]
got pong, 22, with, 3, vector of count (cluster event ), Broker::Data, [data=broker::data{(1, 2, 3)}]
got pong, 23, with, 3, vector of count (cluster publish), Broker::Data, [data=broker::data{(1, 2, 3)}]
got pong, 24, with, 3, vector of count (cluster event ), Broker::Data, [data=broker::data{(1, 2, 3)}]
sending pings, 4, time, 42.0
got pong, 25, with, 4, time (cluster publish), Broker::Data, [data=broker::data{42000000000ns}]
got pong, 26, with, 4, time (cluster event ), Broker::Data, [data=broker::data{42000000000ns}]
got pong, 27, with, 4, time (cluster publish), Broker::Data, [data=broker::data{42000000000ns}]
got pong, 28, with, 4, time (cluster event ), Broker::Data, [data=broker::data{42000000000ns}]
got pong, 29, with, 4, time (cluster publish), Broker::Data, [data=broker::data{42000000000ns}]
got pong, 30, with, 4, time (cluster event ), Broker::Data, [data=broker::data{42000000000ns}]

View file

@ -0,0 +1,17 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
got ping, 0, count, Broker::Data, [data=broker::data{1}]
got ping, 0, count, Broker::Data, [data=broker::data{1}]
got ping, 0, count, Broker::Data, [data=broker::data{1}]
got ping, 1, string, Broker::Data, [data=broker::data{a string}]
got ping, 1, string, Broker::Data, [data=broker::data{a string}]
got ping, 1, string, Broker::Data, [data=broker::data{a string}]
got ping, 2, port, Broker::Data, [data=broker::data{42/tcp}]
got ping, 2, port, Broker::Data, [data=broker::data{42/tcp}]
got ping, 2, port, Broker::Data, [data=broker::data{42/tcp}]
got ping, 3, vector of count, Broker::Data, [data=broker::data{(1, 2, 3)}]
got ping, 3, vector of count, Broker::Data, [data=broker::data{(1, 2, 3)}]
got ping, 3, vector of count, Broker::Data, [data=broker::data{(1, 2, 3)}]
got ping, 4, time, Broker::Data, [data=broker::data{42000000000ns}]
got ping, 4, time, Broker::Data, [data=broker::data{42000000000ns}]
got ping, 4, time, Broker::Data, [data=broker::data{42000000000ns}]
got finish!