Transaction
The commit coordinator: it runs a program as one commit of the store, and joins nested commits
to the one already running. run opens a native transaction with
Store.transaction, and inside it every write, such as a log append or a write a host enlists, runs as a
step through operation, and every read through step, one at a time, so that a read never
interleaves with writes the store has staged. A write that fails fails the whole commit, even
when its caller catches the failure, and once its program ends the commit closes and rejects
late writes. Everything built over one store shares one coordinator, from Log.layer, so their
writes join one commit.
Since v0.2.0
Combinators
Section titled “Combinators”withoutAppends
Section titled “withoutAppends”Runs program so that every write through operation in it, appends included, fails with
WriteForbidden, giving reason: for code that may update stores in the commit but must not
append to its logs, such as a journal’s projections.
Signature
declare const withoutAppends: <A, E, R>( program: Effect.Effect<A, E, R>, reason: string) => Effect.Effect<A, E, Exclude<R, Forbidden>>Since v0.2.0
Constructors
Section titled “Constructors”Construct a transaction coordinator over host storage. Each acquisition owns its commits: a commit one coordinator opened cannot be joined through another.
Signature
declare const make: Effect.Effect< { readonly run: <A, E, R>(program: Effect.Effect<A, E, R>) => Effect.Effect<A, E | Error, Remaining<R>> readonly operation: <A, E, R>(program: Effect.Effect<A, E, R>) => Effect.Effect<A, E | Error, Remaining<R>> readonly step: <A, E, R>(program: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> }, never, Store.Store>Since v0.2.0
Errors
Section titled “Errors”Aborted (class)
Section titled “Aborted (class)”A write in the commit had failed, though its caller caught the failure, so the commit rolls
back; later writes in it fail with this too. cause is the first failure.
Signature
declare class AbortedSince v0.2.0
Closed (class)
Section titled “Closed (class)”The commit had ended when a write or a nested commit tried to use it, such as from a fiber that outlived it.
Signature
declare class ClosedSince v0.2.0
Concurrent (class)
Section titled “Concurrent (class)”A commit’s storage work began a step while another fiber’s step was running. A commit runs its reads and writes one at a time, so await each before the next; concurrent work in one commit is a defect of the program that started it, raised as a defect and aborting the commit.
Signature
declare class ConcurrentSince v0.2.0
Error (type alias)
Section titled “Error (type alias)”What running a commit can fail with: storage’s errors and uncertain outcomes, and the coordinator’s own errors.
Signature
type Error = StoreError.StoreError | Store.CommitUncertain | Aborted | Closed | Foreign | WriteForbiddenSince v0.2.0
Foreign (class)
Section titled “Foreign (class)”A write reached a commit it does not belong to: one another coordinator opened, a native transaction no coordinator opened, or an entry of another log or commit, where a caller checks what it is given against its commit.
Signature
declare class ForeignSince v0.2.0
WriteForbidden (class)
Section titled “WriteForbidden (class)”A write was attempted where writes are forbidden, such as by code that may update stores but not
append; reason says which.
Signature
declare class WriteForbiddenSince v0.2.0
Layers
Section titled “Layers”Provide one transaction coordinator over host storage.
Signature
declare const layer: Layer.Layer<Transaction, never, Store.Store>Since v0.2.0
Models
Section titled “Models”Remaining (type alias)
Section titled “Remaining (type alias)”What a program run as a commit still requires once the commit provides its scope and
Store.Transaction.
Signature
type Remaining<R> = Exclude<Exclude<R, Scope.Scope>, Store.Transaction>Since v0.2.0
Services
Section titled “Services”Transaction (class)
Section titled “Transaction (class)”The commit coordinator of one store, shared by Log and whatever a host builds over it, such as a
journal of facts. make builds it over Store.Store, and layer provides it.
Signature
declare class TransactionSince v0.2.0