Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add JSON Lines Support to KV Store #126

Merged
merged 3 commits into from
Jul 26, 2023
Merged

Conversation

jshlbrd
Copy link
Contributor

@jshlbrd jshlbrd commented Jul 26, 2023

Description

  • Adds support for JSON Lines in the JSON File KV store

Motivation and Context

GJSON has native support for JSON Lines and this is the simplest way to support using them as a KV store.

How Has This Been Tested?

Integration tested using the development app. The test can be recreated with these configs:

kv.json

{"a":1}
{"b":2}
{"c":3}
{"d":4}
{"e":5}

process.libsonnet

local sub = import '../../build/config/substation.libsonnet';

local processors = [
  {
    processor: sub.interfaces.processor.kv_store(
      options={
        type: 'get',
        kv_options: sub.interfaces.kv_store.json_file(
          settings={file: 'kv.json', is_lines: true}
        )
      },
      settings={key: 'bar', set_key: 'kv_store'}
    )
  },
];

{
  processors: sub.helpers.flatten_processors(processors),
}

data.json

{"foo":"a"}
{"bar":"b"}
{"baz":"c"}
{"qux":"d"}
{"quux":"e"}

The results are:

{"foo":"a","kv_store":null}
{"bar":"b","kv_store":2}
{"baz":"c","kv_store":null}
{"qux":"d","kv_store":null}
{"quux":"e","kv_store":null}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@jshlbrd jshlbrd marked this pull request as ready for review July 26, 2023 21:50
@jshlbrd jshlbrd requested a review from a team as a code owner July 26, 2023 21:50
@jshlbrd jshlbrd merged commit 667ceb3 into main Jul 26, 2023
5 checks passed
@jshlbrd jshlbrd deleted the jshlbrd/kv-json-lines branch July 26, 2023 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants