Skip to content
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 auth command #427

Merged
merged 2 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@

package dev.profunktor.redis4cats.algebra

trait ConnectionCommands[F[_]] extends Ping[F]
trait ConnectionCommands[F[_]] extends Ping[F] with Auth[F]

trait Ping[F[_]] {
def ping: F[String]
def select(index: Int): F[Unit]
}

trait Auth[F[_]] {
def auth(password: CharSequence): F[Boolean]
gvolpe marked this conversation as resolved.
Show resolved Hide resolved
def auth(username: String, password: CharSequence): F[Boolean]
}
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,18 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift: Log, K, V](
override def select(index: Int): F[Unit] =
conn.async.flatMap(c => blocker.delay(c.select(index))).void

override def auth(password: CharSequence): F[Boolean] =
async
.flatMap(c => F.delay(c.auth(password)))
.futureLift
.map(_ == "OK")

override def auth(username: String, password: CharSequence): F[Boolean] =
async
.flatMap(c => F.delay(c.auth(username, password)))
.futureLift
.map(_ == "OK")

/******************************* Server API **********************************/
override val flushAll: F[Unit] =
async.flatMap(c => F.delay(c.flushall())).futureLift.void
Expand Down