Skip to content

Releases: emqx/hocon

0.42.0

Choose a tag to compare

@zmstone zmstone released this 04 Mar 10:01

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/#"
      ~"""
    }
  }
}

0.41.0

Choose a tag to compare

@zmstone zmstone released this 15 Feb 09:39
cbfb5f0

Added support for multiline string indentation.

Feature can be summarised as in README.md

  • Quotes next to triple-quotes needs to be escaped, otherwise they are discarded.
    Meaning """a"""" is parsed as a but not a", to crrectly express a", it must be one of below:
    • Escape the last ": """a\"""";
    • Or add ~ around the string value: """~a"~""" (see 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.
    • Backslashes are treated as escape characters, i.e. should be escaped with another backslash; (NOTE: changed in 0.42.0)
    • There is no need to escape quotes in multiline strings, but it's allowed. (NOTE: changed in 0.42.0)

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/#"
      ~"""
    }
  }
}

0.39.9

Choose a tag to compare

@zhongwencool zhongwencool released this 19 Jun 01:28
0c90b33

What's Changed

  • fix: builtin type don't convert from_string when value is integer by @zhongwencool in #259

Full Changelog: 0.39.8...0.39.9

0.39.8

Choose a tag to compare

@zhongwencool zhongwencool released this 10 Jun 11:21
fad34ad

What's Changed

  • fix(hocon_token): fix scan error message format by @zmstone in #257
  • feat: transform atom to binary if serializable=true by @zhongwencool in #258

Full Changelog: 0.39.7...0.39.8

0.39.5

Choose a tag to compare

@zhongwencool zhongwencool released this 04 May 15:51
1ef1695

What's Changed

  • test: add a test case to cover array of union default value fill by @zmstone in #251
  • fix: map converter only works on map, but not each of its value by @zmstone in #252
  • fix: merge struct when mix alias by @zhongwencool in #253
  • fix: convert to different union type crash by @zhongwencool in #254

Full Changelog: 0.39.4...0.39.5

0.35.0

Choose a tag to compare

@zhongwencool zhongwencool released this 11 Jan 06:38
437ad44

What's Changed

  • feat(tags): add support for tagging schemas by @thalesmg in #214
  • refactor: do not log overriding structs by @zmstone in #220

Full Changelog: 0.34.0...0.35.0

0.31.0

Choose a tag to compare

@zhongwencool zhongwencool released this 28 Nov 12:53
8dc0b2e

What's Changed

Full Changelog: 0.30.0...0.31.0

0.28.3

Choose a tag to compare

@zhongwencool zhongwencool released this 07 Jul 06:55
0fdf1ad

What's Changed

Full Changelog: 0.28.2...0.28.3

0.28.1

Choose a tag to compare

@zhongwencool zhongwencool released this 01 Jun 08:49
e50e632

What's Changed

  • feat: allow early return when throw in validations/translations by @zhongwencool in #200

Full Changelog: 0.28.0...0.28.1

0.28.0

Choose a tag to compare

@zhongwencool zhongwencool released this 31 May 00:41
229abbb

What's Changed

Full Changelog: 0.27.5...0.28.0