logging/Manager: Implement DelayTokenType as an actual opaque

With a bit of tweaking in the JavaScript plugin to support opaque types, this
will allow the delay functionality to work there, too.

Making the LogDelayToken an actual opaque seems reasonable, too. It's not
supposed to be user inspected.
This commit is contained in:
Arne Welzel 2023-11-27 18:18:08 +01:00
parent 2dbb467ba2
commit 5e046eee58
13 changed files with 130 additions and 32 deletions

View file

@ -106,3 +106,17 @@ hook Log::log_stream_policy(rec: Info, id: Log::ID)
Log::delay(id, rec);
Log::delay(id, rec);
}
@TEST-START-NEXT
# Delay twice, never release, print the token value and its JSON representation.
hook Log::log_stream_policy(rec: Info, id: Log::ID)
{
if ( id != LOG )
return;
print network_time(), "log_stream_policy", id, rec$uid;
local token = Log::delay(id, rec);
print "token", token;
print "to_json(token)", to_json(token);
}

View file

@ -33,16 +33,6 @@ hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
@TEST-START-NEXT
@load base/protocols/conn
hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
# Wrong token for delay_finish()
local token = Log::delay(id, rec);
Log::delay_finish(id, rec, 42);
}
@TEST-START-NEXT
@load base/protocols/conn
hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
# Wrong record for delay_finish()
@ -53,16 +43,6 @@ hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
@TEST-START-NEXT
@load base/protocols/conn
hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
# Wrong token type for delay_finish()
local token = Log::delay(id, rec);
Log::delay_finish(id, rec, "42");
}
@TEST-START-NEXT
@load base/protocols/conn
hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
# Delay underflow.

View file

@ -31,3 +31,25 @@ hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
Log::delay(id, rec, post_delay_cb);
}
@TEST-START-NEXT
# Bad token type 1
@load base/protocols/conn
hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
# Wrong token type for delay_finish()
local token = Log::delay(id, rec);
Log::delay_finish(id, rec, "42");
}
@TEST-START-NEXT
# Bad token type 2
@load base/protocols/conn
hook Log::log_stream_policy(rec: Conn::Info, id: Log::ID)
{
# Wrong token type for delay_finish()
local token = Log::delay(id, rec);
Log::delay_finish(id, rec, 42);
}