Store

abstract class Store(val config: StoreConfig) : AutoCloseable

One store instance of the node, wow.stores.<name>, as its StoreProvider opened it: it opens each context's log, snapshots and timers on their first use, and the checkpoints, leases, failure ledger and reservations the contexts whose stores it holds share, and remembers what creates their schemas (createSchemas).

A backend subclasses it and opens its ports in the open* functions, each returning the port Opened with what creates its schema, so that no port is opened without it; the node calls them once each (a context's log once per context), so a port is never opened twice, and runs createSchemas when it starts.

What a store opens it closes (close): each port that holds something of its own (a connection it keeps, say) implements AutoCloseable, and the store closes it once, in reverse order of opening, then runs closeStore.

Constructors

Link copied to clipboard
constructor(config: StoreConfig)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val durable: Boolean

Whether the store outlives the node and is shared by the nodes of the service: a store in memory is not, so a node with a log on it serves one node alone and routes its commands locally.

Link copied to clipboard
open val holdsLogs: Boolean

Whether the store holds logs (with their checkpoints, leases, timers and ledger).

Link copied to clipboard

Whether the store holds snapshots.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val location: Any

The database the store writes in, as two stores would share it (a DataSource, a client and a database name): two stores whose logs share one would share their partition sequences, so the node refuses them.

Link copied to clipboard

The store's name, wow.stores.<name>.

Link copied to clipboard

Whether the store may be an aggregate type's primary snapshot store, the one its commands load their state from and its state reads read: one that holds snapshots, unless it only holds a copy beside a primary, as a search index read in near real time does.

Link copied to clipboard
Link copied to clipboard

The type of its provider, StoreProvider.type.

Functions

Link copied to clipboard
override fun close()

Closes the store once nothing reads it any more, which the host that opened it calls once the node and its queries stopped: what it holds of its own, not the resources the host gave it (StoreConfig.resources), which their owner closes. Each port it opened that is AutoCloseable is closed, in reverse order of opening, then closeStore runs, every one even when another fails; the first failure is thrown, the later ones suppressed by it (Closing). Closing it again does nothing, and a closed store opens no port.

Link copied to clipboard

Creates the schemas of what the store opened so far, where they are missing: each port's once, so calling it again only creates those of the ports opened since. The node calls it when it starts; a host may call it earlier, before anything else reads the stores.

Link copied to clipboard
open fun <F : Any> facet(type: Class<F>): F?

The facet of type the store has, null when it has none: a capability a backend opts into beyond the ports, read by the module that knows the facet's type. The documented facets are StorePool, the connections the store draws from, and the query side me.ahoo.wow.query.store.StoreQueries (:query), the snapshot and events queries over what the store holds. A facet is a capability, never a way around a port: what a port does, its facet does not do again.

Link copied to clipboard
inline fun <reified F : Any> Store.facet(): F?

The facet of type F this store has (Store.facet), null when it has none.

Link copied to clipboard
fun log(context: String, partitions: Int): EventLog

context's log on this store, of partitions partitions.

Link copied to clipboard
fun openedLog(context: String): EventLog?

context's log on this store, when it was opened.

Link copied to clipboard
open suspend fun probe()

Checks that the store answers, as the node's health samples it: a cheap round trip to the database (a pooled connection's validity, a ping), bounded by the caller; it throws when the store does not answer. Nothing by default, for a store in memory.

Link copied to clipboard

context's snapshots on this store.

Link copied to clipboard

The one-round-trip read of context's snapshots with their log's tail, when this store holds both in one database and can read them together; null otherwise. The runtime asks it once context's log and snapshots on this store are open, for the aggregate types whose log and primary snapshots are both here.

Link copied to clipboard
fun timers(context: String, partitions: Int): TimerStore

context's timers on this store, of a log of partitions partitions: a timer's partition is its owner's (TimerStore).

Link copied to clipboard
open override fun toString(): String