Skip to content

Instantly share code, notes, and snippets.

Created July 2, 2013 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/935b3f77e1bf88565ada to your computer and use it in GitHub Desktop.
Save anonymous/935b3f77e1bf88565ada to your computer and use it in GitHub Desktop.
case class SendMessage(actionName: String, messageType: String, content: Any, ttl: Long, guaranteed: Boolean, nberOfDataChanges: Int, checks: List[Check[_, _]], next: ActorRef, session: Session, duration: Duration = Duration.Undefined)
class SendStartActionBuilder(val channelName: String,
val actionName: EvaluatableString,
val queryString: EvaluatableString,
val positionalParameters: List[EvaluatableString],
val namedParameters: Map[String, EvaluatableString],
val nberOfDataChanges: Int,
val checks: List[MttpCheck[_, _]],
val duration: Duration = Duration.Undefined,
val next: ActorRef = null) extends ActionBuilder {
def withNext(next: ActorRef): ActionBuilder = new SendStartActionBuilder(channelName, actionName, queryString, positionalParameters, namedParameters, nberOfDataChanges, checks, duration, next)
def build(registry: ProtocolConfigurationRegistry): ActorRef = system.actorOf(Props(new SendStartAction(channelName, actionName, queryString, positionalParameters, namedParameters, nberOfDataChanges, checks, duration, next)))
}
class SendStartAction(channelName: String,
actionName: EvaluatableString,
queryString: EvaluatableString,
positionalParameters: List[EvaluatableString],
namedParameters: Map[String, EvaluatableString],
val nberOfDataChanges: Int,
checks: List[Check[_, _]],
val duration: Duration,
val next: ActorRef)
extends ClientChannelAction(actionName) {
def execute(aSession: Session) {
if (aSession.isAttributeDefined(channelName)) {
val bucket = new Bucket
val requestId = Buckets.addBucket(bucket)
val query = new Query(requestId,
queryString(aSession),
positionalParameters.map(content => content(aSession)).toList.asJava,
namedParameters.mapValues(value => value(aSession)).toMap.asJava,
"", -1, Array(1, 0))
val actor = aSession.getAttribute(channelName).asInstanceOf[ActorRef]
actor ! SendMessage(actionName(aSession), "query.start", query, -1, false, nberOfDataChanges, checks, next, aSession, duration)
} else {
next ! aSession
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment