The client code is tiny and is all based on the Java API (although it's in Scala). Even for people not familar with Scala it should be readable. I'm curious if somebody sees a fatal flaw or something that could be improved.
def withSession[T](block: ClientSession => T): T = {
val session = new ClientSession(host, port, user, pass)
try {
block(session)
}
finally {
session.close()
}
}
def withDbSession[T](database: String)(block: ClientSession => T): T = {
withSession {
session =>
session.execute(new Open(database))
session.execute(new Set("autoflush", "false"))
val result = block(session)
session.execute(new Flush())
result
}
}
def add(database: String, path: String, document: String) =
withDbSession(database)(_.add(path, new ByteArrayInputStream(document.getBytes("utf-8"))))
This add() function gets called about a million times, ha ha, literally.