Class CounterResolver

  • All Implemented Interfaces:
    EventResolver, TemplateResolver<LogEvent>

    public class CounterResolver
    extends Object
    implements EventResolver
    Resolves a number from an internal counter.

    Configuration

     config      = [ start ] , [ overflowing ] , [ stringified ]
     start       = "start" -> number
     overflowing = "overflowing" -> boolean
     stringified = "stringified" -> boolean
     
    Unless provided, start and overflowing are respectively set to zero and true by default.

    When overflowing is set to true, the internal counter is created using a long, which is subject to overflow while incrementing, though garbage-free. Otherwise, a BigInteger is used, which does not overflow, but incurs allocation costs.

    When stringified is enabled, which is set to false by default, the resolved number will be converted to a string.

    Examples

    Resolves a sequence of numbers starting from 0. Once Long.MAX_VALUE is reached, counter overflows to Long.MIN_VALUE.
     {
       "$resolver": "counter"
     }
     
    Resolves a sequence of numbers starting from 1000. Once Long.MAX_VALUE is reached, counter overflows to Long.MIN_VALUE.
     {
       "$resolver": "counter",
       "start": 1000
     }
     
    Resolves a sequence of numbers starting from 0 and keeps on doing as long as JVM heap allows.
     {
       "$resolver": "counter",
       "overflowing": false
     }