Comments (13)
Yeah, and you don't need to parse anything for implementing such behavior.
so is this approach not desirable unstable...VasuDevrani:kvrocks:init_INFO
Yeah, it looks a bit ugly. We can have a more intuitive design for this feature.
from kvrocks.
Yeah, it looks a bit ugly. We can have a more intuitive design for this feature.
i feel confused about the more intuitive design is this close to that 292bdbe? otherwise its out of scope for me (at least for now, will have to wait for someone else's PR or if someone can guide me around the better approach).
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
std::map<SectionNameTy, std::map<KeyTy, ValueTy>>
(where ValueTy = something like std::variant<int, std::string>)
So we can return this format and transform it into JSON or TEXT at the end.
from kvrocks.
In details, we can have such small functions, like:
auto GetPersistenceInfo() -> std::map<KeyTy, ValueTy>;
auto GetServerInfo() -> std::map<KeyTy, ValueTy>;
auto GetPWhateverInfo() -> std::map<KeyTy, ValueTy>;
And then at the function that can generate all info (not real C++ code):
std::map<..> func_map = {{"persistence", GetPersistenceInfo}, ...}
auto all_info = func_map.filter(selected_info_sections).map(x -> x.call())
if (JSON) generateJsonOutput(all_info)
else (TXT) generateTxtOutput(all_info)
from kvrocks.
do we want INFO command to return output in json fomat when INFO JSON
(JSON specified in command) otherwise plain text?
from kvrocks.
I think for compatibility, it should be INFO [<section_name>] [FORMAT (TXT | JSON)]
.
from kvrocks.
im struggling with parsing the output to json, this line of code outputs string which looks like
"# Clients\r\nmaxclients:10000\r\nconnected_clients:1\r\nmonitor_clients:0\r\nblocked_clients:0\r\n"
using jsoncons::json::parse
throws ser_error (unsupported format) and I should not directly append the string as is to the json.
should i create a custom parsing function to convert it something like?
{"clients":{"blocked_clients":"0\r","connected_clients":"1\r","maxclients":"10000\r","monitor_clients":"0\r"}}
from kvrocks.
TBH I cannot get your point. Why do you want to parse it as JSON? It's just not JSON.
from kvrocks.
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 INFO [<section_name>] [FORMAT (TXT | JSON)]
:
INFO
: returns info in default plain text format.
INFO <section>
: section info in plain text format.
INFO all FORMAT JSON
: returns the entire info in JSON format.
INFO <section> FORMAT JSON
: returns just section info in JSON.
INFO <section> FORMAT TXT
: section info in plain text format.
from kvrocks.
Yeah, and you don't need to parse anything for implementing such behavior.
from kvrocks.
Yeah, and you don't need to parse anything for implementing such behavior.
so is this approach not desirable
unstable...VasuDevrani:kvrocks:init_INFO
from kvrocks.
Yeah, it looks a bit ugly. We can have a more intuitive design for this feature.
i feel confused about the more intuitive design
is this close to that 292bdbe?
otherwise its out of scope for me (at least for now, will have to wait for someone else's PR or if someone can guide me around the better approach).
from kvrocks.
auto GetPersistenceInfo() -> std::map<KeyTy, ValueTy>; auto GetServerInfo() -> std::map<KeyTy, ValueTy>; auto GetPWhateverInfo() -> std::map<KeyTy, ValueTy>;
we already does have some function like GetServerInfo that uses string stream and returns string, should i overwrite them to return std::map<KeyTy, ValueTy>
from kvrocks.
auto GetPersistenceInfo() -> std::map<KeyTy, ValueTy>; auto GetServerInfo() -> std::map<KeyTy, ValueTy>; auto GetPWhateverInfo() -> std::map<KeyTy, ValueTy>;
we already does have some function like GetServerInfo that uses string stream and returns string, should i overwrite them to return
std::map<KeyTy, ValueTy>
Yeah you can update these methods.
from kvrocks.
Related Issues (20)
- Move the performance benchmark to website HOT 3
- Optimize the implementation of IntervalSet intersection HOT 2
- [Build] Add supports for build kvrocks with UBSAN
- [Tools] Add a git commit hook for clang-format checking HOT 4
- should we start the compaction_checker_range thread if it's not configed. HOT 3
- TLS test case seems broken
- Improve consistency and isolation semantics by adding Context parameter to DB API HOT 19
- Improve error handling and logging for Retryable IO Errors HOT 13
- Add support for the TOUCH command HOT 2
- Potential data inconsistency issues? HOT 2
- Transaction with FlushDB:DeleteRange unsupported in WriteBatchWithIndex
- A new version of search key and metadata encoding
- Is stream column family useful to be a seperate cf instead of merging into subkey cf? HOT 4
- [OSPP 2024] Tracking issues: Enhance Kvrocks Transaction Syntax
- Improve and unify the RESP error message HOT 3
- Force PR titles to follow the conventional commit format HOT 1
- Docker images with Debian or Ubuntu HOT 4
- [Bug] XINFO overflow when deleting pending message and consumer HOT 5
- Support passing a slot range in CLUSTERX MIGRATE HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kvrocks.