apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.19k stars 1.29k forks source link

General-purpose JSON output for CLI commands #4210

Open brownleej opened 3 years ago

brownleej commented 3 years ago

When building other tools that wrap around FDB's CLI commands, we've hit a couple of general problems. The first problem is that parsing the status json output from the CLI can be error-prone, since the command isn't guaranteed to output a valid JSON document; it may output other information before outputting any JSON. The second problem is that commands beside status json don't provide machine-readable output. For instance, when running exclusion commands, the output is in text form, so running exclusions through other tools requires parsing the text in a way that is brittle to future changes. Could we consider having an option to request output in JSON form for most or all commands, in a separate stream from other output?

sfc-gh-clin commented 3 years ago

I am working on exposing all management APIs(Issue: #2960 ) through the transaction interface via special keys(\xff\xff). For those not be able to do based on transactions, I added c functions for them. The work is nearly finished with only several commands to be added. After that, I will need to refactor fdbcli to based on C API thus we get rid of the version issues. This issue is different from what I am working on since this generally needs to refactor the output format of fdbcli. But we should have a meeting on how to refactor the fdbcli in general. For example, as described here, having a json output option for fdbcli. In general, I think having a general output format of fdbcli instead of the current one, which is user-defined output with no forced-format, is much better in many cases like testing. cc @xumengpanda