Class CaptureSessionStore

java.lang.Object
com.shaft.capture.storage.CaptureSessionStore

public final class CaptureSessionStore extends Object
Thread-safe start, append, checkpoint, stop, and interruption lifecycle for one capture file.
  • Constructor Details

    • CaptureSessionStore

      public CaptureSessionStore(Path path)
      Creates a store for one capture path.
      Parameters:
      path - session JSON path
    • CaptureSessionStore

      public CaptureSessionStore(Path path, CaptureJsonCodec codec)
      Creates a store with an explicit codec.
      Parameters:
      path - session JSON path
      codec - capture codec
  • Method Details

    • start

      public void start(CaptureSession session)
      Starts and persists a new incomplete session.
      Parameters:
      session - new incomplete session
    • append

      public CaptureSession append(CaptureEvent event)
      Appends an event and atomically publishes the updated session.
      Parameters:
      event - event to append
      Returns:
      updated session
    • append

      public CaptureSession append(CaptureEvent event, List<ExternalTestDataReference> references, RedactionSummary summary)
      Appends an event with privacy references and summary in one atomic snapshot.
      Parameters:
      event - event to append
      references - external references used by the event
      summary - safe privacy summary
      Returns:
      updated session
    • nextSequence

      public long nextSequence()
      Atomically reserves and returns the next unique event sequence number for this session, based on the highest sequence currently persisted. Intended for recorders (for example CaptureNetworkRecorder, via ManagedCaptureRecorder) that build a CaptureEvent off the main CaptureEventPipeline thread and must still avoid colliding with its independently-assigned sequence numbers.
      Returns:
      the next sequence number, one greater than the highest currently persisted
    • checkpoint

      public CaptureSession checkpoint(Checkpoint checkpoint)
      Adds a checkpoint and atomically publishes the updated session.
      Parameters:
      checkpoint - checkpoint to add
      Returns:
      updated session
    • checkpoint

      public CaptureSession checkpoint(Checkpoint checkpoint, RedactionSummary summary)
      Adds a checkpoint and its sanitized-text summary atomically.
      Parameters:
      checkpoint - checkpoint to add
      summary - safe privacy summary
      Returns:
      updated session
    • updateEvents

      public CaptureSession updateEvents(UnaryOperator<List<CaptureEvent>> operation)
      Atomically rewrites the event list.
      Parameters:
      operation - event list rewrite
      Returns:
      updated session
    • stop

      public CaptureSession stop(Instant stoppedAt)
      Completes and atomically publishes the session.
      Parameters:
      stoppedAt - stop time
      Returns:
      completed session
    • markIncomplete

      public CaptureSession markIncomplete(Instant interruptedAt)
      Explicitly marks an interrupted session while keeping it readable.
      Parameters:
      interruptedAt - interruption time
      Returns:
      incomplete interrupted session
    • discard

      public void discard()
      Deletes the session file and forgets the in-memory snapshot, so an intentional discard can never be undone by the vanished-file self-heal.
      Throws:
      UncheckedIOException - when the file exists but could not be deleted
    • read

      public CaptureSession read()
      Reads the latest complete file snapshot.
      Returns:
      current session
    • steps

      public List<CaptureStep> steps()
      Returns the current step list derived from the on-disk session, so the recorder UI can rehydrate its step list from the server instead of page-scoped storage across navigations.
      Returns:
      ordered safe step summaries for every event carrying a client action ID
    • networkTransactions

      public List<NetworkTransaction> networkTransactions()
      Returns the current network transactions derived from the on-disk session.
      Returns:
      ordered safe network transaction summaries