object Service {
val http = new Http() with thread.Safety
// actually sending u/pw over message body (log message above was just to make it clear)
def login(user:String, password:String) =
http.when(code => match {
case 200|201|202|203|204 => true
case _ => Login.loginFailure(code)}}
) (loginUrl << compact(render(Map("username"->user, "password"->password))) ># {json =>
//do stuff here
})
}
INF: [console logger] dispatch: [server] GET [path]/login?u=username&pw=password HTTP/1.1
Awesome, Thanks for the reply! I will try to get you some details early this week.
Maven dependency being used:<dependency><groupId>net.databinder</groupId><artifactId>dispatch-lift-json_2.9.1</artifactId><version>0.8.5</version></dependency>Appears to be pulling in the following jars:
Since you think the one client/connection would be the safest, I will work on finalizing my code base to explicitly close those connections. Related to that (my second question), does anyone in this group use any cool scala-y patterns that are a good/common way to encapsulate the "when", "execute handler", and "shutdown" logic? If not, no biggie... but, being a newb, I worry that not coding in proper scala fashion can itself create problems.Would starting down the path of the following pseudo code be "scala approved"? =) I may run into a bunch of difficulties getting it implemented due to variability of when functions, handlers, and responses (but, usually those are what lead me to finding new scala-y ways of doing things):object HttpHelper {def http_close(when, handler) {http = new Httpvar res = http.when(when)(handler)http.shutdown()res}}
I can look into the dispatch/reboot to see if I can get you some stats. We did use "web securify" as a quick way to throw a ton of login attempts at the application. In non-reboot testing, the thread-safe client would obviously fail around 50 or so. And, the "new client/connection" would run fine (we let the test run to about 30,000 hits) even letting the gc() clean up connections. I can put together some test based on the web securify tool to compare with dispatch/reboot if that would be helpful until I have time to get a full performance testing tool in place.
Dispatch Version Info (I can test updating this if 0.8.7 is available in the maven repository)
Application code:Since you think the one client/connection would be the safest, I will work on finalizing my code base to explicitly close those connections. Related to that (my second question), does anyone in this group use any cool scala-y patterns that are a good/common way to encapsulate the "when", "execute handler", and "shutdown" logic? If not, no biggie... but, being a newb, I worry that not coding in proper scala fashion can itself create problems.
[...]
Performance comparison:
I can look into the dispatch/reboot to see if I can get you some stats. We did use "web securify" as a quick way to throw a ton of login attempts at the application. In non-reboot testing, the thread-safe client would obviously fail around 50 or so. And, the "new client/connection" would run fine (we let the test run to about 30,000 hits) even letting the gc() clean up connections. I can put together some test based on the web securify tool to compare with dispatch/reboot if that would be helpful until I have time to get a full performance testing tool in place.