-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #9 initial write on connect (AUTH and SELECT)
- Loading branch information
Valerian Barbot
committed
Sep 14, 2013
1 parent
7b29998
commit 9e883d5
Showing
11 changed files
with
209 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package redis | ||
|
||
import redis.protocol.RedisReply | ||
import scala.concurrent.{ExecutionContext, Promise, Future} | ||
import scala.collection.immutable.Queue | ||
import akka.actor.ActorRef | ||
|
||
|
||
trait Request { | ||
implicit val executionContext: ExecutionContext | ||
|
||
def send[T](redisCommand: RedisCommand[_ <: RedisReply, T]): Future[T] | ||
} | ||
|
||
trait ActorRequest { | ||
implicit val executionContext: ExecutionContext | ||
|
||
def redisConnection: ActorRef | ||
|
||
def send[T](redisCommand: RedisCommand[_ <: RedisReply, T]): Future[T] = { | ||
val promise = Promise[T]() | ||
redisConnection ! Operation(redisCommand, promise) | ||
promise.future | ||
} | ||
} | ||
|
||
trait BufferedRequest extends redis.Request { | ||
implicit val executionContext: ExecutionContext | ||
|
||
val operations = Queue.newBuilder[Operation[_, _]] | ||
|
||
override def send[T](redisCommand: RedisCommand[_ <: RedisReply, T]): Future[T] = { | ||
val promise = Promise[T]() | ||
operations += Operation(redisCommand, promise) | ||
promise.future | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.