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
package vertx.mods.tests.verticles.java; | |
/* | |
* Copyright 2011-2012 the original author or authors. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
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
package com.campudus.gorilla; | |
import java.util.Set; | |
import org.jboss.netty.handler.codec.http.Cookie; | |
import org.jboss.netty.handler.codec.http.CookieDecoder; | |
import org.jboss.netty.handler.codec.http.CookieEncoder; | |
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.eventbus.EventBus; | |
import org.vertx.java.core.eventbus.Message; |
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
package com.campudus.scalasnippets | |
import actors.Actor._ | |
import java.util.concurrent.atomic.AtomicInteger | |
import scala.annotation.tailrec | |
object SomeAsyncTests { | |
def asyncFunction(i: Int)(doWhenDone: => Unit) = actor { | |
println("doing stuff " + i) |
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
package tests; | |
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.http.HttpServerRequest; | |
import org.vertx.java.core.http.RouteMatcher; | |
import org.vertx.java.deploy.Verticle; | |
public class HttpClientExample extends Verticle { | |
public void start() { |
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
package reactivemongotest | |
import scala.concurrent.Await | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
import scala.concurrent.duration.DurationInt | |
import org.junit.Test | |
import reactivemongo.api.MongoConnection | |
import reactivemongo.bson.BSONDocument | |
import reactivemongo.bson.BSONInteger |
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
package reactivemongotest | |
import scala.concurrent.Await | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
import scala.concurrent.duration.DurationInt | |
import org.junit.Test | |
import reactivemongo.api.MongoConnection | |
import reactivemongo.bson.BSONDocument | |
import reactivemongo.bson.BSONInteger |
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
eventBus.replaceData("address", "read-action", "replace-action", { | |
"id" : 15 | |
}, | |
// action on replace computation | |
function (readData) { | |
var replacedData = readData; | |
replacedData.nickname = replacedData.nickname.toLowerCase(); | |
return replacedData; | |
}, | |
// action on success |
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
trait MessageHelpers { | |
type Validated[T] = Either[List[String], T] | |
type Decoder[T] = Message[JsonObject] => Validated[T] | |
def validatedMap[X, Y](v: Validated[X], f: X => Y): Validated[Y] = v match { | |
case Left(errors) => Left(errors) | |
case Right(x) => Right(f(x)) | |
} | |
private def missingField[T](field: String): T => Validated[T] = { maybe => |
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
// Set the project name to the string 'My Project' | |
name := "SBTProject" | |
// The := method used in Name and Version is one of two fundamental methods. | |
// The other method is <<= | |
// All other initialization methods are implemented in terms of these. | |
version := "1.0" | |
scalaVersion := "2.10.1" |
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
[19:20:14] <purplefox> Narigo: ok found the problem | |
[19:20:24] <purplefox> Narigo: the problem is you're playing with threads in your verticle | |
[19:20:38] <purplefox> Narigo: you're using a fork join | |
[19:20:49] <purplefox> Narigo: and calling deployVerticle on the result of that | |
[19:20:56] <purplefox> Narigo: which is not the vert.x thread | |
[19:21:16] <purplefox> Narigo: so vert.x doesn't know what verticle you're in | |
[19:21:28] <purplefox> Narigo: basically - don't use other threads in verticles | |
[19:21:38] <purplefox> Narigo: you're also opening yourself up to race conditions | |
[19:22:15] <purplefox> Narigo: I'll add some better exceptions in vert.x so you'll get a better message next time you do this | |
[19:22:37] <purplefox> Narigo: "deploVerticle called from a non Vert.x thread. You are a very naughty boy!!" |
OlderNewer