nee-core / dev.neeffect.nee.effects.tx / TxEffect

TxEffect

class TxEffect<DB, R : TxProvider<DB, R>> : Effect<R, TxError>, Logging

Transaction like effect.

Use for SQL/JDBC operations, but anything that works on some "resource - conection" can be implemented using TxProvider interface.

Parameters

DB - a resource, a connection

R - provider of resource (also must support update of connection state)

Constructors

<init>

Transaction like effect.

TxEffect(requiresNew: Boolean = false)

Functions

wrap

Wrap a business function in a given effect

fun <A> wrap(f: (R) -> A): (R) -> Pair<Out<TxError, A>, R>

Extension Functions

andThen

Composition of effects.

fun <R1, E1, R2 : R1, E2> Effect<R2, E2>.andThen(otherEffect: Effect<R1, E1>): Effect<R2, Either<E1, E2>>

anyError

fun <R, E> Effect<R, E>.anyError(): Effect<R, Any>

logger

Use it to log using slf4j.

fun <T : Logging> T.logger(): Logger

plus

operator fun <R1, E1, R2 : R1, E2 : E1> Effect<R2, E2>.plus(otherEffect: Effect<R1, E1>): Effect<R2, E1>

then

infix fun <R1, E1, R2 : R1, E2> Effect<R2, E2>.then(otherEffect: Effect<R1, E1>): Effect<R2, Either<E1, E2>>

with

infix fun <R1, E1, R2 : R1, E2 : E1> Effect<R2, E2>.with(otherEffect: Effect<R1, E1>): Effect<R2, E1>