cluster/serializer/broker: Do not special case Broker::Data anymore

The previous approach ignored the fact that nested / inner values might
also be Broker::Data values. I'm not super sure about the validity of
the test, because it's essentially demonstrating any-nesting, but
it's not leading to extra Broker::Data encoding.
This commit is contained in:
Arne Welzel 2025-08-15 21:33:52 +02:00
parent 9e70d8b8ad
commit f57a1263d4
4 changed files with 24 additions and 16 deletions

View file

@ -35,3 +35,10 @@ got pong, 27, with, 4, time (cluster publish), Broker::Data, [data=broker::data{
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}]
sending pings, 5, R, [c=42, a=[[c=42, a=hello]]]
got pong, 31, with, 5, R (cluster publish), Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got pong, 32, with, 5, R (cluster event ), Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got pong, 33, with, 5, R (cluster publish), Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got pong, 34, with, 5, R (cluster event ), Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got pong, 35, with, 5, R (cluster publish), Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got pong, 36, with, 5, R (cluster event ), Broker::Data, [data=broker::data{(42, ((42, hello)))}]

View file

@ -14,4 +14,7 @@ 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 ping, 5, R, Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got ping, 5, R, Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got ping, 5, R, Broker::Data, [data=broker::data{(42, ((42, hello)))}]
got finish!

View file

@ -34,9 +34,14 @@ global pong: event(c: count, what: string, val: any) &is_used;
global i = 0;
global pongs = 0;
type R: record {
c: count;
a: any;
};
event send_any()
{
if ( i > 4 )
if ( i > 5 )
return;
local val: any;
@ -48,8 +53,10 @@ event send_any()
val = 42/tcp;
else if ( i == 3 )
val = vector(1, 2, 3);
else
else if ( i == 4 )
val = double_to_time(42.0);
else
val = R($c=42, $a=vector(R($c=42, $a="hello")));
print "sending pings", i, type_name(val), val;
Cluster::publish_hrw(Cluster::worker_pool, cat(i), ping, i, type_name(val), val);
@ -64,10 +71,10 @@ event pong(c: count, what: string, val: any)
++pongs;
print "got pong", pongs, "with", c, what, type_name(val), val;
# The manager sends 5 types of pings, in 3 different ways. The worker
# answers each ping in two ways, for a total of 30 expected pongs at the
# The manager sends 6 types of pings, in 3 different ways. The worker
# answers each ping in two ways, for a total of 36 expected pongs at the
# manager. Every batch of pings involves 6 pongs.
if ( pongs == 30 )
if ( pongs == 36 )
Cluster::publish(Cluster::worker_topic, finish);
else if ( pongs > 0 && pongs % 6 == 0 )
{