Skip to content

Commit

Permalink
startuptime is now reported when it isn't exceeded.
Browse files Browse the repository at this point in the history
limitenforcer's enterStartup* functions now receive a reference to a
OneOf an exception or a duration. Which can be populated by the elapsed
duration if the limit was not exceeded.
  • Loading branch information
danlapid committed Aug 12, 2024
1 parent 992c357 commit ecbb6ea
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 120 deletions.
10 changes: 5 additions & 5 deletions src/workerd/io/limit-enforcer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ class IsolateLimitEnforcer {
// When the returned scope object is dropped, if a limit was exceeded, then `error` will be
// filled in to indicate what happened, otherwise it is left null.
virtual kj::Own<void> enterStartupJs(
jsg::Lock& lock, kj::Maybe<kj::Exception>& error) const = 0;
jsg::Lock& lock, kj::OneOf<kj::Exception, kj::Duration>& limitErrorOrTime) const = 0;

// used to enforce limits on Python script startup.
virtual kj::Own<void> enterStartupPython(
jsg::Lock& lock, kj::Maybe<kj::Exception>& error) const = 0;
jsg::Lock& lock, kj::OneOf<kj::Exception, kj::Duration>& limitErrorOrTime) const = 0;

// Like enterStartupJs(), but used when compiling a dynamically-imported module.
virtual kj::Own<void> enterDynamicImportJs(
jsg::Lock& lock, kj::Maybe<kj::Exception>& error) const = 0;
jsg::Lock& lock, kj::OneOf<kj::Exception, kj::Duration>& limitErrorOrTime) const = 0;

// Like enterStartupJs(), but used to enforce tight limits in cases where we just intend
// to log an error to the inspector or the like.
virtual kj::Own<void> enterLoggingJs(
jsg::Lock& lock, kj::Maybe<kj::Exception>& error) const = 0;
jsg::Lock& lock, kj::OneOf<kj::Exception, kj::Duration>& limitErrorOrTime) const = 0;

// Like enterStartupJs(), but used when receiving commands via the inspector protocol.
virtual kj::Own<void> enterInspectorJs(
jsg::Lock& lock, kj::Maybe<kj::Exception>& error) const = 0;
jsg::Lock& lock, kj::OneOf<kj::Exception, kj::Duration>& limitErrorOrTime) const = 0;

// Notifies the enforcer that a request has been completed. The enforcer is more lenient about
// limits if several requests have been completed, vs. if limits are broken right off the bat.
Expand Down
Loading

0 comments on commit ecbb6ea

Please sign in to comment.