14. Misc

This section documents various functions that do not fit in any other sections.

14.1. Threads

haka.current_thread() → id
  • id (number) – The current thread’s index.

Allows to check what thread is currently running.


Abort current execution. This function will throw an error that will unwind the stack up to the topmost protected call.

14.2. Exit

  • exit_func (function) – Function to run at exit time.

Registers a callback that will be called when Haka exits.

14.3. Time

object time

Time object.

haka.time(secs) → t
  • secs (number) – Number of seconds since the epoch (1970-01-01T00:00:00Z ISO 8601).
  • t (time) – New time representation.

Build a new time object.


Seconds and nano-seconds as integer value.

const <time>.seconds

Seconds as floating point value.

tostring(<time>) → str
  • str (string) – Human readable representation of the time.

Convert the time to human readable form.

14.4. General Events

Haka also uses global events to notify for interesting messages. Those events can be used by a regular rule as usual.

event haka.events.started()

Event triggered when the Haka configuration is loaded and Haka is ready to process packets.

event haka.events.exiting()

Event triggered when Haka is exiting.