Add couch db plugable persistence module scheme.

This commit is contained in:
Yung-Luen Lan 2010-10-04 14:51:28 +08:00
parent f47f3191da
commit 9c3da5a083
3 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,47 @@
package se.scalablesolutions.akka.persistence.couchdb
import se.scalablesolutions.akka.actor.{newUuid}
import se.scalablesolutions.akka.stm._
import se.scalablesolutions.akka.persistence.common._
object CouchDBStorage extends Storage {
type ElementType = Array[Byte]
def newMap: PersistentMap[ElementType, ElementType] = newMap(newUuid.toString)
def newVector: PersistentVector[ElementType] = newVector(newUuid.toString)
def newRef: PersistentRef[ElementType] = newRef(newUuid.toString)
def getMap(id: String): PersistentMap[ElementType, ElementType] = newMap(id)
def getVector(id: String): PersistentVector[ElementType] = newVector(id)
def getRef(id: String): PersistentRef[ElementType] = newRef(id)
def newMap(id: String): PersistentMap[ElementType, ElementType] = new CouchDBPersistentMap(id)
def newVector(id: String): PersistentVector[ElementType] = new CouchDBPersistentVector(id)
def newRef(id: String): PersistentRef[ElementType] = new CouchDBPersistentRef(id)
}
/**
* Implements a persistent transactional map based on the CouchDB storage.
*
* @author
*/
class CouchDBPersistentMap(id: String) extends PersistentMapBinary {
val uuid = id
val storage = CouchDBStorageBackend
}
/**
* Implements a persistent transactional vector based on the CouchDB
* storage.
*
* @author
*/
class CouchDBPersistentVector(id: String) extends PersistentVector[Array[Byte]] {
val uuid = id
val storage = CouchDBStorageBackend
}
class CouchDBPersistentRef(id: String) extends PersistentRef[Array[Byte]] {
val uuid = id
val storage = CouchDBStorageBackend
}

View file

@ -0,0 +1,14 @@
package se.scalablesolutions.akka.persistence.couchdb
import se.scalablesolutions.akka.stm._
import se.scalablesolutions.akka.persistence.common._
import se.scalablesolutions.akka.util.Logging
import se.scalablesolutions.akka.config.Config.config
private [akka] object CouchDBStorageBackend extends
MapStorageBackend[Array[Byte], Array[Byte]] with
VectorStorageBackend[Array[Byte]] with
RefStorageBackend[Array[Byte]] with
Logging {
// need couch db implementation!
}

View file

@ -499,6 +499,8 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
new AkkaHbaseProject(_), akka_persistence_common)
lazy val akka_persistence_voldemort = project("akka-persistence-voldemort", "akka-persistence-voldemort",
new AkkaVoldemortProject(_), akka_persistence_common)
lazy val akka_persistence_couchdb = project("akka_persistence_couchdb", "akka_persistence_couchdb",
new AkkaCouchDBProject(_), akka_persistence_common)
}
// -------------------------------------------------------------------------------------------------------------------
@ -598,6 +600,9 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
override def testOptions = createTestFilter( _.endsWith("Suite"))
}
class AkkaCouchDBProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
}
// -------------------------------------------------------------------------------------------------------------------
// akka-kernel subproject