Interface StateStoreProvider

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StateStoreProvider
Supplies the StateStore that holds a strategy's state for one instrument.

This is the injection seam for advanced state backends: the default provider hands out an in-memory store, while a deployment that needs state to outlive the process (restart rehydration, shared/remote state) injects its own implementation. The engine calls a provider once per instrument and memoizes the result, so an implementation may open a connection or allocate per-instrument resources without a per-tick cost — but it must be safe to call from the thread that first sees that instrument.

Everything a strategy persists for an instrument flows through the store returned here: the strategy's own update() state, the state of every window listener it registers, and the execution callbacks' state. One instrument, one namespace — which is what a persistent backend needs to rehydrate coherently. Keys are therefore shared across a strategy's windows: name them so two windows cannot collide.

Downstream of this seam the engine passes a plain Supplier<StateStore>: an indicator or group resolves its store through the supplier only when it actually has to write, so a provider that opens a connection is never entered for an instrument nobody listens to.

  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the state store for the given instrument.
  • Method Details

    • getStateStore

      StateStore getStateStore(Instrument instrument)
      Returns the state store for the given instrument.
      Parameters:
      instrument - the instrument whose state is requested
      Returns:
      the state store (never null)