Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am ericwush on github.
  • I am ericbado (https://keybase.io/ericbado) on keybase.
  • I have a public key ASAcdYuwOHUhRlNJlrcD7fjqo4pmTVQqi3zBwRL1vFLvqwo

To claim this, I am signing this object:

mysql> insert into `test`.`maxwell` set id = 1, daemon = 'Stanislaw Lem';
maxwell: {
"database": "test",
"table": "maxwell",
"type": "insert",
"ts": 1449786310,
"xid": 940752,
"commit": true,
"data": { "id":1, "daemon": "Stanislaw Lem" }
}
var WebSocketClient = function(address) {
var socket = new WebSocket(address);
socket.onopen = function() {
console.log("Connection established with " + address);
};
socket.onclose = function(event) {
console.log(event);
};
...
import scalaz.\/
object Models {
case class SuccessResponse(payload: JsValue)
case class ErrorResponse(message: Message)
// it's up to you to define subscription model
case class SubscriptionMessage(userId: String)
case class ThrowableOrSubscriptionsMessage(disjunction: \/[Exception, SubscriptionMessage])
import play.api.libs.json.{Json, Writes}
object JsonUtils {
def stringify[T](objekt: T)(implicit tjs: Writes[T]): String = {
Json.stringify(Json.toJson(objekt))
}
}
import akka.actor.{Actor, ActorRef, ActorSystem, PoisonPill, Props}
import akka.event.Logging
import Models.{SubscriptionMessage, _}
import JsonUtils.stringify
import play.api.libs.json.{JsString, Json}
object WebSocketActor {
def props(out: ActorRef, redisSubActorProps: Props, actorSystem: ActorSystem): Props =
Props(new WebSocketActor(out, redisSubActorProps, actorSystem))
}
import akka.actor.{Actor, ActorRef, Props}
import com.redis._
import Models.{NotificationEvent, RedisSubscribeMessage, RedisUnsubscribeMessage}
import play.api.Logger
import play.api.libs.json.{JsError, JsSuccess, Json}
import scala.util.Try
object RedisSubActor {
def props(redis: Redis): Props = {
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))
}
}
@ericwush
ericwush / blog_event.json
Created July 8, 2017 12:06
Sample json used by blog
{
"user_id": "23",
"record_id": "I2FE9w",
"event": "UPDATED"
}