ByteArrayBody + Redis Feed #551

Merged
merged 1 commit into from Jun 9, 2012

Projects

None yet

2 participants

@krishnenc
Contributor

Byte Array Body
Redis Feed

Usage :
https://gist.github.com/2888230
https://gist.github.com/2888208

Please review and let me know if any modifications required

@slandelle slandelle merged commit 99695c3 into gatling:master Jun 9, 2012
@slandelle slandelle pushed a commit that referenced this pull request Jun 9, 2012
Stephane Landelle Clean up after #551 pull request c522692
@slandelle slandelle commented on the diff Jun 9, 2012
.../com/excilys/ebi/gatling/redis/util/RedisHelper.scala
+ */
+package com.excilys.ebi.gatling.core.feeder.redis.util
+
+object RedisHelper {
+
+ /*
+ Generate Redis protocol required for mass insert
+ i.e generateRedisProtocol("LPUSH", "SIM", "SOMETHING COOL!")
+ */
+ def generateRedisProtocol(d: String*) = {
+ var protocol = ""
+ val length = d.toList.length
+ protocol = "*" + length + "\r\n"
+ d.toList map {
+ case x =>
+ protocol = protocol + "$" + x.length + "\r\n" + x + "\r\n"
@slandelle
slandelle Jun 9, 2012 Member

I've never used Redis, but \r\n seems OS specific.
Shouldn't we use StringHelper.END_OF_LINE (ie System.getProperty("line.separator")) here?

@krishnenc
krishnenc Jun 9, 2012 Contributor

I think the protocol (http://redis.io/topics/protocol) is OS independent.
The client hardcodes the line ending as well: https://github.com/debasishg/scala-redis/blob/master/src/main/scala/com/redis/RedisProtocol.scala#L17
However i will make a test on a Windows box on Monday to verify.
I will try to send a few unit tests for these changes as well.
Thks,
Krishnen

@slandelle
slandelle Jun 9, 2012 Member

"\r\n" is typically Windows, so if your code runs on an X-platform, it should be fine, don't bother.

Do you think you could also write a few lines on the Feeders wiki page when we'll do the release?
https://github.com/excilys/gatling/wiki/Feeders

Thanks again!

@krishnenc
Contributor

No pb will do that. When are you planning the next release?

@slandelle
Member

Hopefully at the end of the week.

@krishnenc
Contributor

Hi Stephane,

I've added a few lines in my version of the wiki :

https://github.com/krishnenc/gatling/wiki/Feeders#wiki-redis
https://github.com/krishnenc/gatling/wiki/HTTP (Under section Method specific methods)

How do we go about to merge it into yours?

Cheers,
Krishnen

@slandelle
Member

Good question, let me check this.
BTW, I renamed redisfeed into redisFeeder in Predef in order to be consistant with other feeders.

Thanks!

Stephane

@krishnenc
Contributor

OK cool , I've updated the example to reflect this change as well.

@slandelle slandelle was assigned Jun 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment