Skip to content

0.42.0

Latest
Compare
Choose a tag to compare
@zmstone zmstone released this 04 Mar 10:01
· 29 commits to master since this release

Non-backward compatible refactoring based on 0.41.0 for triple-quote strings.

  • Immediate quote before triple-quote is invalid sytax.
    • """"a"""" is invalid because there are 4 closing quotes instead of three. See workarounds below.
  • Multiline strings allow indentation (spaces, not tabs).
    If ~\n (or ~\r\n) are the only characters following the opening triple-quote, then it's a multiline string with indentation:
    • The first line ~\n is discarded.
    • The closing triple-quote can be either """ or ~""" (~ allows the string to end with " without escaping).
    • Indentation is allowed but not required for empty lines.
    • Indentation level is determined by the least number of leading spaces among the non-empty lines.
    • If the closing triple-quote takes the whole line, it's allowed to be indented less than other lines,
      but if it's indented more than other lines, the spaces are treated as part of the string.
    • Backslash is NOT a escape character.
    • If a string has three consecutive quotes, there are two workarounds:
      • Make use of string concatenation, and only escape the triple-quotes. e.g.
        a = """~
                line1
            ~"""
            "line2\"\"\"\n"
            """~
                line3
            ~"""
        
      • Use normal string with escape sequence.
        For example: a = "line1\nline2\"\"\"\nline3\n"

Some examples:

rule_engine {
  ignore_sys_message = true
  jq_function_default_timeout = 10s
  rules {
    a_WH_D {
      actions = ["http:a_WH_D"]
      description = ""
      enable = true
      metadata {created_at = 1707562385536}
      name = ""
      sql = """~
        SELECT
          *
        FROM
          "#",
          "$events/message_delivered",
          "$events/message_acked",
          "$events/message_dropped",
          "$events/client_connected",
          "$events/client_disconnected",
          "$events/client_connack",
          "$events/client_check_authz_complete",
          "$events/session_subscribed",
          "$events/session_unsubscribed",
          "$events/delivery_dropped"~"""
    }
    rule_rc0w {
      actions = [
        {
          args {
            mqtt_properties {}
            payload = "${.}"
            qos = 0
            retain = false
            topic = "republish-event/${clientid}"
            user_properties = ""
          }
          function = republish
        },
        {function = console}
      ]
      enable = true
      metadata {created_at = 1707389712653}
      name = ""
      sql = """~
        SELECT
          *
        FROM
          "$events/client_connected",
          "$events/client_disconnected"
      ~"""
    }
    rule_xlu4 {
      actions = [
        {function = console}
      ]
      description = ""
      enable = true
      metadata {created_at = 1706611936022}
      name = ""
      sql = """~
        SELECT
          *
        FROM
          "t/#"
      ~"""
    }
  }
}