Home

Awesome

Key-Gen JSON Smartmodule

SmartModule to read values from JSON Records, compute a digest, and update record key. This SmartModule is map type, where each record-in generates a new records-out.

Input Record

A JSON object:

{
  "description": "This is the description of my JSON object",
  "last_build_date": "Tue, 18 Apr 2023 15:00:01 GMT",
  "link": "http://www.example.com",
  "pub_date": "Mon, 17 Apr 2023 16:08:23 GMT",
  "title": "My Json Object Title"
}

Transformation spec

The transformation spec requires one keyword:

In this example, we'll use the following transformation spec:

  transforms:
    - uses: infinyon-labs/key-gen-json@0.1.1
      with:
        spec:
          lookup:
            - "/pub_date"
            - "/last_build_date"
          key_name: "dedup_key"

Outpot Record

A JSON object augmented with dedup_key, and a digest:

{
  "dedup_key": "3193200642d322d171dd4c05875741ff7a4fc0f7a467b52d514d5ce273d4f762",
  "description": "This is the description of my JSON object",
  "last_build_date": "Tue, 18 Apr 2023 15:00:01 GMT",
  "link": "http://www.example.com",
  "pub_date": "Mon, 17 Apr 2023 16:08:23 GMT",
  "title": "My Json Object Title"
}

Build binary

Use smdk command tools to build:

smdk build

Inline Test

Use smdk to test:

smdk test --file ./test-data/input.json --raw -e spec="{\"lookup\":[\"\/pub_date\", \"\/last_build_date\"], \"key_name\": \"dedup_key\"}"

Cluster Test

Use smdk to load to cluster:

smdk load 

Test using transform.yaml file:

smdk test --file ./test-data/input.json --raw  --transforms-file ./test-data/transform.yaml

Cargo Compatible

Build & Test

cargo build
cargo test