oriana
package oriana
- Alphabetic
- By Inheritance
- oriana
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
ConfiguredRetrySchedule
extends FixedRetrySchedule
A configured schedule derives its delays from the config key "retry_db_delay_millis", where it expects to find a number list.
A configured schedule derives its delays from the config key "retry_db_delay_millis", where it expects to find a number list. The numbers are interpreted as millisecond delays.
-
class
DBExecution
[DBContext <: ExecutableDatabaseContext, T] extends Actor
Internal implementation actor for a single database interaction.
Internal implementation actor for a single database interaction. This actor handles the actual invocation of an operation, including failure / retry logic.
- DBContext
context type
- T
result type
-
trait
DBInitializer
[-InitCtx <: ExecutableDatabaseContext] extends DBOperation[InitCtx, InitComplete.type]
Initializers prepare the Database on startup, ensuring it is in a usable state once application traffic reaches it.
Initializers prepare the Database on startup, ensuring it is in a usable state once application traffic reaches it. They may be simple (as in, create tables if absent) or elaborate. The init process needs to be complete before the first "user" operation can be attempted.
-
type
DBOperation[-Context <: ExecutableDatabaseContext, +Result] = (Context) ⇒ Future[Result]
Type for operations - simple DB interactions that are not part of a transaction.
Type for operations - simple DB interactions that are not part of a transaction. Since they may have multiple, disjoined stages, they can not be retried and can have partial results (depending on which parts of them were executed).
-
case class
DBSinkSettings
(cancelOnError: (Throwable) ⇒ Boolean = _ => true, parallelism: Int = 1) extends Product with Serializable
Options modifying the behaviour of a database sink
Options modifying the behaviour of a database sink
- cancelOnError
should the sink cancel the stream on an error? The default will always cancel
- parallelism
limit of parallel items to process. Default is single-transaction
-
type
DBStreamOperation[-Context <: DatabaseContext, +Result, -E <: Effect] = (Context) ⇒ DBIOAction[_, Streaming[Result], E]
Models a streamable DB operation.
Models a streamable DB operation. These operations should not modify state. Note the missing [DatabaseCommandExecution] type to prevent direct execution
-
trait
DBTransaction
[Context <: DatabaseContext, +R] extends AnyRef
Transactions are all-or-nothing sets of operations on the database.
Transactions are all-or-nothing sets of operations on the database. They can either succeed (which applies all modifications that may have arisen simultaneously), or fail. If they fail, the oriana actors will attempt the transaction again until its retry allowance is exhausted.
Note the absence of the DatabaseCommandExecution trait in the
Context
, which prevents direct access to the database - and thus allows making the transaction retryable- Context
context subclass required by this transaction
- R
result type
-
class
DatabaseActor
extends Actor
The central point of oriana, an actor that enables an init lifecycle for a database, and a parent to individual operation actors.
The central point of oriana, an actor that enables an init lifecycle for a database, and a parent to individual operation actors.
This actor goes through 3 lifecvcle stages. Uninitialized, where it accepts simple operations and transactions (operations for short), changes to its retry configuration and changes to the initializer. It will queue, but not execute any operations it receives. These queued operations will use the retry configuration that was active when they were first received. Once it received the [DatabaseActor.Init] message, it will evolve to the initializing state.
While the actor is initializing, it executes the configured initializer. It will accept operations and keep them queued, and accept changes to the retry configuration. If initialization succeeds, it will enter the ready state. If initialization fails, the failure will trigger an exception on this actor, which will (in turn) lead to the actors supervisor deciding the further fate of the database access. Upon entering the ready state, all previously queued operations are fired
In the ready state, the actor accepts retry policy changes and operations, which start executing immediately
-
trait
DatabaseCommandExecution
extends AnyRef
Marks a context as supporting direct execution.
Marks a context as supporting direct execution. Contexts with direct execution can be used for "simple" DBOperations, but because transactionality cannot be guaranteed, will not be subject to retries.
-
trait
DatabaseContext
extends AnyRef
Database context encapsulate a driver, its api and a list of all tables.
Database context encapsulate a driver, its api and a list of all tables. You are encouraged to add members for your tables when you implement your class. For example:
class MyContext extends DatabaseContext { val driver = MySQLDriver val api = driver.api val ponies: TableAccess[Pony] = new PonyTableAccess(driver) val riders: TableAccess[Rider] = new RiderTableAccess(driver) val ponyReviews: TableAccess[PonyReview] = new PonyReviewTableAccess(driver) val allTables = List(ponies, riders, ponyReviews) }
-
final
case class
DatabaseName
(name: String) extends AnyVal with Product with Serializable
Wrapper type representing a database name.
Wrapper type representing a database name. The name is supposed to be the actor name of the database actor.
- name
name of the actor
-
type
ExecutableDatabaseContext = DatabaseContext with DatabaseCommandExecution
Context type for operations - mixes in the DatabaseCommandExecution trait in to grant access to the database object of the context
-
class
FixedRetrySchedule
extends RetrySchedule
Attempts a fixed number of retries, with constant time delays
-
trait
NoRetry
extends AnyRef
Mix in this trait to an exception to make the exception "fatal", and prevent the normal transaction handling from retrying on this failure.
Mix in this trait to an exception to make the exception "fatal", and prevent the normal transaction handling from retrying on this failure. This feature is useful to distinguish "business domain" errors which will never go away from technical glitches and transient conditions (such as a lost DB connection), which a wait-and-retry can eventually defeat.
-
trait
RetrySchedule
extends AnyRef
Defines a retry schedule for failures of an DBTransaction.
-
abstract
class
SimpleDatabaseContext
extends DatabaseContext
A base class for Contexts that derive their database connection from a typesafe configuration.
A base class for Contexts that derive their database connection from a typesafe configuration. The driver object still needs to be determined "by hand", or by calling the alternate constructor, which offers a way to determine it by configuration
-
trait
TableAccess
[TableMappingType <: AbstractTable[_]] extends AnyRef
Defines access to a slick table.
Defines access to a slick table. This includes a query object (for CRUD operations) and a schema create action.
- TableMappingType
type of slick FRM table class
-
class
TransactionSubscriber
[Context <: DatabaseContext, T] extends Subscriber[T]
Subscriber implementing the sink semantics.
Subscriber implementing the sink semantics. Do not use manually, instead use executeAsSink()
- Context
context type
- T
input type
Value Members
-
def
executeAsFlow[Context <: DatabaseContext, In, Out](op: (In) ⇒ DBStreamOperation[Context, Out, _])(implicit arg0: Manifest[Out], actorRefFactory: ActorRefFactory, timeout: Timeout, ec: ExecutionContext, actorName: DatabaseName): Flow[In, Out, NotUsed]
Performs a database-using operation as a flow element.
Performs a database-using operation as a flow element.
- Context
Context type (useful for table access)
- In
input type
- Out
output type
- op
operation to execute
- actorRefFactory
factory for accessing the lower-level ([executeDBOperation] operation.
- timeout
ask timeout for each execution
- ec
context to use
- actorName
database actor name
- returns
flow modelling the specified transformation
-
def
executeAsSink[Context <: DatabaseContext, T](op: (T) ⇒ DBTransaction[Context, _], settings: DBSinkSettings = DBSinkSettings())(implicit actorRefFactory: ActorRefFactory, timeout: Timeout, ec: ExecutionContext, actorName: DatabaseName): Sink[T, Future[Int]]
Creates a sink that executes the specified database transaction for every element published to the stream.
Creates a sink that executes the specified database transaction for every element published to the stream. The sink has some options that can be set to modify its operation. The operation materializes a future that returns the number of successfully-processed transactions.
- Context
Context type (useful for table access)
- T
input type
- op
operation to perform
- settings
settings for the sink
- actorRefFactory
factory for accessing the lower-level ([executeDBOperation] operation.
- timeout
ask timeout for each execution
- ec
context to use
- actorName
database actor name
- returns
sink instantiated to execute the specified transaction per-element.
-
def
executeAsSource[Context <: DatabaseContext, T](op: DBStreamOperation[Context, T, _])(implicit arg0: Manifest[T], actorRefFactory: ActorRefFactory, timeout: Timeout, ec: ExecutionContext, actorName: DatabaseName): Source[T, NotUsed]
Creates a source from a streamable database operation
Creates a source from a streamable database operation
- Context
context type (useful for table access)
- T
emitted type
- op
operation
- actorRefFactory
actor factory for communication to the database actor
- timeout
ask timeout for the initial creation of the sink, not for each operation
- ec
context to use
- actorName
database actor name
- returns
source backed by the passed DB operation
-
def
executeDBOperation[T](op: DBOperation[_ <: ExecutableDatabaseContext, T])(implicit arg0: Manifest[T], actorRefFactory: ActorRefFactory, timeout: Timeout, ec: ExecutionContext, actorName: DatabaseName): Future[T]
Syntactic sugar for access to the database.
Syntactic sugar for access to the database. The block argument is scheduled as a [DBOperation] to the implicit database.
executeDBOperation { ctx: MyContext with DatabaseCommandExecution => // ... generate actions, and execute them with ctx.database.run ctx.database.run(DBIO.successful(42)) }
- T
operation return type
- op
operation to perform
- actorRefFactory
most likely an actor system
- timeout
timeout for ask operation(s) used under the hood to implement the Future
- ec
execution context for ask operation(s) used under the hood to implement the Future
- actorName
name for the database actor
- returns
future with operation result
-
def
executeDBTransaction[Context <: DatabaseContext, T](op: DBTransaction[Context, T])(implicit arg0: Manifest[T], actorRefFactory: ActorRefFactory, timeout: Timeout, ec: ExecutionContext, actorName: DatabaseName): Future[T]
Syntactic sugar for access to the database.
Syntactic sugar for access to the database. The block argument is scheduled as a [DBTransaction] to the implicit database. Transactions may be attempted multiple times in case of failures, making them good candidates for idiom such as optimistic locking.
executeDBTransaction { ctx: MyContext => // ... generate actions, which will be wrapped with transactionally and executed DBIO.successful(42) }
- Context
context type to pass to the transaction
- T
result type of the transaction
- op
transaction to attempt
- actorRefFactory
most likely an actor system
- timeout
timeout for ask operation(s) used under the hood to implement the Future
- ec
execution context for ask operation(s) used under the hood to implement the Future
- actorName
name for the database actor
- returns
future with transaction result
- object DBExecution
-
object
DBTransaction
Companion for the DBTransaction class
- object DatabaseActor
- object DatabaseName extends Serializable
-
object
DefaultSchedule
extends FixedRetrySchedule
The default schedule retries five times, with escalating delays.
The default schedule retries five times, with escalating delays. The retries occur at 100, 200, 300, 400 and 500 ms intervals. This schedule is primarily beneficial to testing and demo environments, and should generally be replaced by a more considered schedule in applications.
-
object
NoRetrySchedule
extends RetrySchedule
Simple schedule that never attempts a retry
-
object
SchemaCreateInitializer
extends DBInitializer[ExecutableDatabaseContext]
Simple initializer that executes create DDL for any missing tables.
Simple initializer that executes create DDL for any missing tables. Does not care or have capability to provide an initial data load.
- object TableAccess