Skip to content

@usine/engine/cursor

Durable storage for cursors that only save work. The module that owns a key passes its schema per call; a stored value that no longer decodes reads as absent and is logged.

  • Context.ServiceClass

readonly Service: object

The service’s operations: what yield* CursorStore returns.

readonly read: <T, E>(key, schema) => Effect.Effect<Option.Option<T>, EnginePersistenceError>

Type Parameter
T
E extends Schema.Json
Parameter Type
key CursorKey
schema Schema.Codec<T, E, never, never>

Effect.Effect<Option.Option<T>, EnginePersistenceError>

readonly write: <T, E>(key, schema, value) => Effect.Effect<void, EnginePersistenceError>

Type Parameter
T
E extends Schema.Json
Parameter Type
key CursorKey
schema Schema.Codec<T, E, never, never>
value T

Effect.Effect<void, EnginePersistenceError>

readonly static layer: Layer<CursorStore, never, RunDatabase>

CursorKey = typeof CursorKey.Type

Identity of one cursor. Cursors only save work, so losing one is safe.

const CursorKey: Schema.brand<Schema.NonEmptyString, "CursorKey">

Identity of one cursor. Cursors only save work, so losing one is safe.