.

Imprimir

Database

Database Component

Definition

case class Database() extends Cell[DatabaseConfig] with ServiceSupport

Description

Component for database interaction. Clients of this component send a DBStatementRequest or StoredProcCall to initiate a group of Database Operations. When the results are ready this component sends out a ResultDescriptor which contains information about the available results. Clients can then request those results to be streamed out with a series of DBResult instances. Each DBResult will contain the result descriptor associated plus a page of data together with an index to indicate the page order.

Contract

  @CellContract(
    Receives[DBStatementRequest], Receives[StoredProcCall],
    Sends[ResultDescriptor], Sends[DBResult]
  )

Where:

case class DBStatementRequest(statements: IndexedSeq[DBStatement])(implicit ctx: CellContext) extends ServiceRequest[DBStatementRequest]
case class StoredProcCall(tag: String, name: String, params: IndexedSeq[Param[_]]) extends DBStatement
case class ResultDescriptor(op: Op, tag:String, subOp: SubOp, subOpIndex: Int, resultType: ResultType)
case class DBResult(descriptor: ResultDescriptor, resultIndex: Long, data: Seq[Any])

Configuration

trait DatabaseConfig extends CellCfg {
  def url:                    String
  def driver:                 String
  def profile:                JdbcProfile
  def user:                   String  = null
  def password:               String  = null
  def keepAliveConnection:    Boolean = false
  def maxResultRecords:       Int     = 1000
  def numThreads:             Int     = 10
  def floorAwaitingRequests:  Int     = 100
  def capAwaitingRequests:    Int     = 200
  def queryQueueSize:         Int     = 2500
}
Table of Contents