-
Notifications
You must be signed in to change notification settings - Fork 6
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
TCP arguments protocol is lacking #11
Comments
Thank you for raising this. You're right that it's unnecessary and inefficient to encode the 1️⃣ We could get away with newline delimited plain text, like this:
The question is whether we'd encode 2️⃣ We could skip parsing the payload entirely and just pass it on to What do you think? |
1️⃣ Not encoding
e.g. 3 lines of arguments:
or for no arguments
Looks somewhat janky, but you're right that it doesn't require encoding it as JSON, so that's a big plus. 2️⃣ seems like a good idea, although I wonder what's the point of the TCP connection then? Simply skipping file creation in the disk? Yeah it makes sense, have core_d only act as a "forwarder" to the service. |
Option 2️⃣ is becoming my preference. I think of Would you be interested in contributing a change for this? |
I am perhaps sensing some confusion here, so let's confirm the understanding first. My understanding is as follows: Option 1core_d adjusts the parsing Protocol
e.g. 3 lines of arguments:
or for no arguments
ServiceStays the same since core_d is still doing the parsing.
Option 2core_d gets rid of the parsing and simply sends the raw data into the service Protocol
ServiceDictates the protocol and parses it however it wants
Is that what you're thinking as well? Also let's remember why JSON was proposed in the first place: it gets rid of whitespace ambiguity for separating the components. Separating them into newlines achieves the same.
If you want any upfront parsing to remain before sending data to the service, then that's not the "Option 2" I am thinking of. |
I see. My proposal is a solution that is a mix of both. I'd change the protocol to be:
The first line is the current working directory, as you stated, we would get rid of the whitespace problem. The second line would be arguments, can be blank, and it's up to the service to parse it. It could be JSON, but core_d would not try to parse it. The remaining text is the Does that make sense? Are am I missing something? |
I understand your idea now. It's similar to the one originally proposed in #11, laid out again for comparison: Protocol
example:
I don't get why cwd gets its own line in your idea, though. Why not encode it in the payload line too like shown above? Well, either way is fine, I suppose. This did give me an idea for an Option 3 which is a simplification of Option 1 from #11. Option 3First line tells to expect N next argument lines, followed by N argument lines, then the text comes next. It would get rid of the Protocol
example (note
or for no arguments
Service
I like Option 3 better since not every service is obligated to use a cwd. It's not limiting because "argument lines" can have whatever the service wants - core_d would not look at it, only split the lines before sending it to the service. If the service wants, It could even be:
i.e. it would allow for your idea as well. I like this Option 3 the most, although I can also accept Option 2 from #11. The other ones are not as "clean" as those IMO. |
I like where this collaborative idea development is going 👍 I'd like to keep the I like the idea of placing the additional arguments on separate lines. That seems cleaner to me too. However, I'm not a fan of specifying the count of argument lines upfront. Could we separate the arguments from the body with a blank line maybe?
|
Yeah, separating them with a blank line looks better than specifying the line count. I'd agree with that format as well. |
The implemented TCP protocol is
The most glaring problem there is that
$PWD
can have spaces and that is not taken into account.Further, I saw that the protocol accepts JSON although it's not documented.
core_d.js/lib/server.js
Lines 25 to 26 in bfe1f7c
Yet another problem there:
text
is supposed to be included in the JSON payload, but it shouldn't; encoding thousands of lines to JSON is costly and there's no reason for it.My suggestion is the following:
i.e. parseData should be like
for the format
as an example:
Summary of the proposal
Even in Bash it's pretty easy to escape the
cwd
for JSON, which would get rid of the spacing problem. Here's how I'm doing it in a script:Upsides for JSON:
The text was updated successfully, but these errors were encountered: