Module chewdata::step::generator

source ·
Expand description

Generate an empty crate::DataResult that you can enrich with the crate::step::Transformer.

It possible to duplicate input data and enrich them after.

§Actions

1 - Get a crate::Context from the input queue.
2 - Extract the crate::DataResult from the crate::Context.
3 - Clone the current crate::Context or it create a new one if empty.
4 - Push the crate::Context into the output queue.
5 - Go to the step 3 n times.
6 - Go to step 1 until the input queue is not empty.

§Configuration

keyaliasDescriptionDefault ValuePossible Values
type-Required in order to use generator stepgeneratorgenerator / g
namealiasName stepnullAuto generate alphanumeric value
data_typedataType of data used for the transformation. skip other data typeokok / err
dataset_sizebatchStack size limit before to push data into the resource though the connector1000unsigned number

§Examples

[
    {
        "type": "generator",
        "name": "my_generator",
        "data_type": "ok",
        "dataset_size": 1000,
    },
    {
        "type": "transformer",
        "actions": [
            {
                "field":"firstname",
                "pattern": "{{ fake_first_name() }}"
            },
            {
                "field":"lastname",
                "pattern": "{{ fake_last_name() }}"
            },
            {
                "field":"city",
                "pattern": "{{ fake_city() }}"
            },
            {
                "field":"password",
                "pattern": "{{ fake_password(min = 5, max = 10) }}"
            },
            {
                "field":"color",
                "pattern": "{{ fake_color_hex() }}"
            }
        ]
    },
    {
        "type": "writer"
    }
]

No input.

output:

[
    {"firstname": "my firstname", "lastname": "my lastname", "city": "my city", "password": "my password", "color": "my color"},
    ...
]

Structs§