-
Notifications
You must be signed in to change notification settings - Fork 456
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
Add option to INFO to return a json payload #2302
Comments
do we want INFO command to return output in json fomat when |
I think for compatibility, it should be |
im struggling with parsing the output to json, this line of code outputs string which looks like
using should i create a custom parsing function to convert it something like? |
TBH I cannot get your point. Why do you want to parse it as JSON? It's just not JSON. |
Maybe i misunderstood, please confirm. The issue wants the support of commands
|
Yeah, and you don't need to parse anything for implementing such behavior. |
so is this approach not desirable |
Yeah, it looks a bit ugly. We can have a more intuitive design for this feature. |
i feel confused about the more intuitive design |
Lines 1211 to 1229 in 292bdbe
I hope you can notice that there is a lot of repetition in your code between if and else, we should avoid this copy-and-paste programming. For me, preventing such code from entering kvrocks codebase is my top priority. In fact, we can see that the result returned by INFO is a format similar to
So we can return this format and transform it into JSON or TEXT at the end. |
In details, we can have such small functions, like:
And then at the function that can generate all info (not real C++ code):
|
we already does have some function like GetServerInfo that uses string stream and returns string, should i overwrite them to return |
Yeah you can update these methods. |
Search before asking
Motivation
try to monitor some specs from my service and would be better to be able to consume them in a format that's easier to consume rather than parsing strings like the kvrocks_exporter does.
Solution
would be nice to expose somenthing like:
INFO `section` JSON/TXT
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: