-
Notifications
You must be signed in to change notification settings - Fork 63
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
Server api #529
Server api #529
Conversation
@mijicd were you able to take a look at this PR? I would like to know if I am on the right track before putting too much effort into it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass done, looks great. I'll do a more thorough review once it's ready. Please specify the PR scope once it's ready for review, and don't forget to reference the issue :).
case object On extends Rule | ||
case object Off extends Rule | ||
case class KeyPattern(pattern: String) extends Rule | ||
case object ResetKeys extends Rule | ||
case class ChannelPattern(pattern: String) extends Rule | ||
case object RestChannels extends Rule | ||
case class AddCommand(command: String, subcommand: Option[String] = None) extends Rule | ||
case class RemoveCommand(command: String) extends Rule | ||
case class AddCategory(category: String) extends Rule | ||
case class RemoveCategory(category: String) extends Rule | ||
case object NoPass extends Rule | ||
case class AddTextPassword(pw: String) extends Rule | ||
case class RemoveTextPassword(pw: String) extends Rule | ||
case class AddHashedPassword(hash: String) extends Rule | ||
case class RemoveHashedPassword(hash: String) extends Rule | ||
case object Reset extends Rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's seal the case classes.
val AllKeys = KeyPattern("*") | ||
val AllChannels = ChannelPattern("*") | ||
val AllCommands = AddCommand("all") | ||
val NoCommands = RemoveCommand("all") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make them final.
* @return | ||
* a list of categories | ||
*/ | ||
final def aclCat(): ZIO[RedisExecutor, RedisError, Chunk[String]] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove ()
. The same applies to all other no-arg functions.
case RespValue.Array(values) => | ||
val flags = ChunkOutput(MultiStringOutput).unsafeDecode(values(1)) | ||
val passwords = ChunkOutput(MultiStringOutput).unsafeDecode(values(3)) | ||
val commnads = MultiStringOutput.unsafeDecode(values(5)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a typo.
flags: List[String], | ||
passwords: List[String], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use Chunk
wherever is possible.
), | ||
suite("UserEntryOutput") ( | ||
testM("read user entry successfully") { | ||
val userEntryRaw = "user default on nopass ~* &* +@all" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd define it in for comprehension, lifted in UIO. The same applies to other occurrences.
@mijicd Thanks for your feedback I will address all your comments and continue implementing the server API commands |
*/ | ||
final def aclLogReset: ZIO[RedisExecutor, RedisError, Unit] = { | ||
val command = RedisCommand(AclLog, StringInput, UnitOutput) | ||
command.run("RESET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better use it like a separate command. Doesn't it work?
AclLogReset
@@ -787,4 +787,76 @@ object Output { | |||
case other => throw ProtocolError(s"$other isn't an integer >= -1") | |||
} | |||
} | |||
|
|||
case object UserinfoOutput extends Output[UserInfo] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case object UserinfoOutput extends Output[UserInfo] { | |
case object UserInfoOutput extends Output[UserInfo] { |
flags: Chunk[String], | ||
firstKey: Int, | ||
lastKey: Int, | ||
step: Int, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, We have to stick with Long type everywhere, cause Redis integer is 64 bit in most cases, according to documentation Resp Integer
Please ignore ApiSpec and zio.package. I will fix them later when I am ready with the PR