This file contains hidden or 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 reactivemongo.bson.BSONDocument | |
import reactivemongo.api.collections.default.BSONCollection | |
import reactivemongo.api.{QueryOpts, DB} | |
import reactivemongo.core.commands.Count | |
import reactivemongo.api.collections.default._ | |
def getDocument(collection: BSONCollection): Future[Option[YourClass]] = { | |
val futureCount = db.command(Count(collection.name)) | |
futureCount.flatMap { count => | |
val skip = Random.nextInt(count) |
This file contains hidden or 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 com.excilys.ebi.gatling.core.Predef._ | |
import com.excilys.ebi.gatling.http.Predef._ | |
import scala.util.Random | |
import com.excilys.ebi.gatling.core.feeder.Feeder | |
class ServiceSimulation extends Simulation { | |
def apply = { | |
val random = new Random | |
random.setSeed(System.currentTimeMillis) |
This file contains hidden or 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
implicit def liftJsonUnmarshaller[A :Manifest] = new UnmarshallerBase[A] { | |
val canUnmarshalFrom = ContentTypeRange(`application/json`) :: Nil | |
def unmarshal(content: HttpContent) = protect { | |
val jsonSource = DefaultUnmarshallers.StringUnmarshaller.unmarshal(content).right.get | |
parse(jsonSource).extract[A] | |
} | |
} | |
implicit def liftJsonMarshaller[A <: AnyRef] = new MarshallerBase[A] { | |
val canMarshalTo = ContentType(`application/json`) :: Nil |
NewerOlder