github.com/Jeffail/benthos/v3@v3.65.0/public/bloblang/function.go (about)

     1  package bloblang
     2  
     3  // Function defines a Bloblang function, arguments are provided to the
     4  // constructor, allowing the implementation of this function to resolve them
     5  // statically when possible.
     6  type Function func() (interface{}, error)
     7  
     8  // FunctionConstructor defines a constructor for a Bloblang function, where a
     9  // variadic list of arguments are provided.
    10  //
    11  // When a function is parsed from a mapping with static arguments the
    12  // constructor will be called only once at parse time. When a function is parsed
    13  // with dynamic arguments, such as a value derived from the mapping input, the
    14  // constructor will be called on each invocation of the mapping with the derived
    15  // arguments.
    16  //
    17  // For a convenient way to perform type checking and coercion on the arguments
    18  // use an ArgSpec.
    19  type FunctionConstructor func(args ...interface{}) (Function, error)
    20  
    21  // FunctionConstructorV2 defines a constructor for a Bloblang function where
    22  // parameters are parsed using a ParamsSpec provided when registering the
    23  // function.
    24  //
    25  // When a function is parsed from a mapping with static arguments the
    26  // constructor will be called only once at parse time. When a function is parsed
    27  // with dynamic arguments, such as a value derived from the mapping input, the
    28  // constructor will be called on each invocation of the mapping with the derived
    29  // arguments.
    30  type FunctionConstructorV2 func(args *ParsedParams) (Function, error)