Last active
July 9, 2017 07:05
-
-
Save ericwush/d703eda7bf2288d03c22f31581b48988 to your computer and use it in GitHub Desktop.
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
import akka.actor.{Actor, ActorRef, Props} | |
import com.redis.{Publish, Publisher} | |
import Models.RedisPublishMessage | |
object RedisPubActor { | |
def props(redis: Redis): Props = { | |
val publisherProps = Props(new Publisher(redis.client)) | |
Props(new RedisPubActor(publisherProps)) | |
} | |
} | |
class RedisPubActor(publisherProps: Props) extends Actor { | |
private val publisher: ActorRef = context.actorOf(publisherProps) | |
def receive: Receive = { | |
case RedisPublishMessage(ch, msg) => publish(ch, msg) | |
} | |
private def publish(channel: String, message: String) = { | |
publisher ! Publish(channel, message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment