PragmaTwice commented on code in PR #1405:
URL: 
https://github.com/apache/incubator-kvrocks/pull/1405#discussion_r1180405528


##########
src/types/redis_stream_base.cc:
##########
@@ -85,39 +79,48 @@ Status ParseStreamEntryID(const std::string &input, 
StreamEntryID *id) {
   return Status::OK();
 }
 
-Status ParseNewStreamEntryID(const std::string &input, NewStreamEntryID *id) {
+std::unique_ptr<NextStreamEntryIDGenerationStrategy> 
ParseNextStreamEntryIDStrategy(const std::string &input) {

Review Comment:
   From my side, I recommend you to use something like 
`StatusOr<std::unique_ptr<NextStreamEntryIDGenerationStrategy>>` instead of 
exceptions, e.g.
   ```c++
   StatusOr<std::unique_ptr<NextStreamEntryIDGenerationStrategy>> 
ParseNextStreamEntryIDStrategy(const std::string &input) {
     ...
     if (...) {
       return {Status::NotOk, "some reason..."};
     } else {
       return std::make_unique<SomeDerivedClass>(...);
     }
     ...
   }
   ```
   And use it as usual:
   ```c++
   auto res = ParseNextStreamEntryIDStrategy(...);
   if (res.IsOK()) {
     (*res)->AnyMethod(); // or `std::unique_ptr x = std::move(*res);`, whatever
   } else {
     // print or forward `res.Msg()`, or `return res` directly
   }
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to