go-ipfs-cmds can support passing stateful encoders #5780
Labels
kind/enhancement
A net-new feature or improvement to an existing feature
need/analysis
Needs further analysis before proceeding
topic/api
Topic api
topic/commands
Topic commands
topic/core-api
Topic core-api
Rationale
This issue comes out of the discussion surrounding #5611. As more and more ipfs commands support some form of streaming response, go-ipfs-cmd encoders are likely to get called more than once, and chaining together correctly, particularly in the case of a text encoder, may require some kind of knowledge about what was sent last.
In the LS case, we need to know, when LS-ing multiple directories, whether the latest directory entry/entries streamed is in the same directory as the last entry streamed, so we can insert a directory hash and possibly column headings before we start with a new directory. We've solved this for now by simply sending the Hash of the directory streamed last as an extra field in all streamed entries. This seems less than ideal, since it's really a client level concern.
Possible Solutions
ls
encoding=text
-- see Add command does not support json encoding #1121 for an example)ls
this is all that's needed and could simply be an extra parameter in the function passed to MakeTypedEncoder.ls
is enough other commands might need to pass different types of state between calls.The text was updated successfully, but these errors were encountered: