Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Repository

Index

Constructors

constructor

  • new Repository(cacheLimit: number, concurrencyLimit: number, logger: DiagnosticsLogger): Repository
  • Parameters

    • cacheLimit: number

      Maximum number of streams to store in memory cache.

    • concurrencyLimit: number

      Maximum number of concurrently running tasks on the streams.

    • logger: DiagnosticsLogger

      Where we put diagnostics messages.

    Returns Repository

Properties

Readonly executionQ

executionQ: ExecutionQueue

Serialize operations on state per streamId.

Readonly inmemory

In-memory cache of the currently running streams.

Readonly loadingQ

loadingQ: ExecutionQueue

Serialize loading operations per streamId.

stateManager

stateManager: StateManager

Instance of StateManager for performing operations on stream state.

Accessors

pinStore

Methods

_loadGenesis

  • _loadGenesis(streamId: StreamID): Promise<[RunningState, boolean]>
  • Helper function for loading at least the genesis commit state for a stream. WARNING: This should only be called from within a thread in the loadingQ!!!

    Parameters

    • streamId: StreamID

    Returns Promise<[RunningState, boolean]>

    a tuple whose first element is the state that was loaded, and whose second element is a boolean representing whether we believe that state should be the most update-to-date state for that stream, or whether it could be behind the current tip and needs to be synced.

add

applyCommit

  • applyCommit(streamId: StreamID, commit: any, opts: CreateOpts | UpdateOpts): Promise<RunningState>

applyCreateOpts

  • applyCreateOpts(streamId: StreamID, opts: CreateOpts): Promise<RunningState>

close

  • close(): Promise<void>

get

  • get(streamId: StreamID): Promise<RunningState | undefined>

handlePinOpts

  • handlePinOpts(state$: RunningState, opts: PinningOpts): Promise<void>

listPinned

  • listPinned(streamId?: StreamID): Promise<string[]>

load

  • load(streamId: StreamID, opts: LoadOpts): Promise<RunningState>
  • Returns a stream from wherever we can get information about it. Starts by checking if the stream state is present in the in-memory cache, if not then checks the state store, and finally loads the stream from pubsub.

    Parameters

    • streamId: StreamID
    • opts: LoadOpts

    Returns Promise<RunningState>

loadAtCommit

  • loadAtCommit(commitId: CommitID, opts: LoadOpts): Promise<SnapshotState>

loadAtTime

  • loadAtTime(streamId: StreamID, opts: LoadOpts): Promise<SnapshotState>

pin

setDeps

streamState

  • streamState(streamId: StreamID): Promise<StreamState | undefined>

unpin

  • unpin(state$: RunningState, opts?: PublishOpts): Promise<void>

updates$

  • updates$(init: StreamState): Observable<StreamState>
  • Updates for the StreamState, even if a (pinned or not pinned) stream has already been evicted. Marks the stream as durable, that is not subject to cache eviction.

    First, we try to get the running state from memory or state store. If found, it is used as a source of updates. If not found, we use StreamState passed as init param as a future source of updates. Anyway, we mark it as unevictable.

    When a subscription to the observable stops, we check if there are other subscriptions to the same RunningState. We only consider the RunningState free, if there are no more subscriptions. This RunningState is subject to future cache eviction.

    Parameters

    • init: StreamState

    Returns Observable<StreamState>