Class SessionManager
Handles session creation, state transitions, and statistics tracking.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void> addBytesProcessed(String sessionId, long bytes) Add the number of processed bytes to the session total.io.smallrye.mutiny.Uni<Void> completeSession(String sessionId, String state) Mark a session as completed and persist its final state.io.smallrye.mutiny.Uni<String> createSession(String connectorId, String crawlId, String accountId, String connectorType, String sourceSystem, String metadata, boolean trackDocuments, boolean deleteOrphans) Create a new crawl session.io.smallrye.mutiny.Uni<CrawlSession> getSession(String sessionId) Retrieve a crawl session by its identifier.io.smallrye.mutiny.Uni<Void> incrementDocumentsFailed(String sessionId) Increment the count of documents that failed processing for a session.io.smallrye.mutiny.Uni<Void> incrementDocumentsFound(String sessionId) Increment the count of documents discovered for a session.io.smallrye.mutiny.Uni<Void> incrementDocumentsProcessed(String sessionId) Increment the count of documents successfully processed for a session.io.smallrye.mutiny.Uni<Void> incrementDocumentsSkipped(String sessionId) Increment the count of documents skipped (not processed) for a session.io.smallrye.mutiny.Uni<Void> updateHeartbeat(String sessionId) Update a session's heartbeat timestamp to the current time.
-
Constructor Details
-
SessionManager
public SessionManager()Default constructor for CDI.
-
-
Method Details
-
createSession
public io.smallrye.mutiny.Uni<String> createSession(String connectorId, String crawlId, String accountId, String connectorType, String sourceSystem, String metadata, boolean trackDocuments, boolean deleteOrphans) Create a new crawl session.If a session already exists for the same
connectorIdandcrawlId, the existing session ID is returned. Otherwise, a new session is persisted in the database and its ID is returned. Reactive semantics: executes on the default worker pool due to blocking persistence. Side effects: inserts a row into thecrawl_sessiontable.- Parameters:
connectorId- Connector IDcrawlId- Client-provided crawl IDaccountId- Account IDconnectorType- Connector typesourceSystem- Source system identifiermetadata- Crawl metadata as JSONtrackDocuments- Whether to track documents for orphan detectiondeleteOrphans- Whether to delete orphans at end- Returns:
- a
Uniemitting the session ID (existing or newly created)
-
getSession
Retrieve a crawl session by its identifier.Reactive semantics: executes on the default worker pool due to database access. Side effects: none (read-only).
- Parameters:
sessionId- unique session identifier- Returns:
- a
Unithat emits theCrawlSessionif found; fails if not found
-
updateHeartbeat
Update a session's heartbeat timestamp to the current time.Reactive semantics: executes on the default worker pool due to database access. Side effects: updates the
lastHeartbeatcolumn for the given session.- Parameters:
sessionId- unique session identifier- Returns:
- a
Unithat completes when the heartbeat has been updated
-
completeSession
Mark a session as completed and persist its final state.Sets the session's
stateandcompletedAttimestamp. No-op if the session does not exist will result in a failure from the repository layer. Reactive semantics: executes on the default worker pool due to database access. Side effects: updates thecrawl_sessionrow for the given session.- Parameters:
sessionId- unique session identifierstate- terminal state to set (e.g.,COMPLETED,FAILED,ABORTED)- Returns:
- a
Unithat completes when the session is marked complete
-
incrementDocumentsFound
Increment the count of documents discovered for a session.Reactive semantics: executes on the default worker pool due to database access. Side effects: increments the
documentsFoundcounter in the session row.- Parameters:
sessionId- unique session identifier- Returns:
- a
Unithat completes after the counter has been incremented
-
incrementDocumentsProcessed
Increment the count of documents successfully processed for a session.Reactive semantics: executes on the default worker pool due to database access. Side effects: increments the
documentsProcessedcounter in the session row.- Parameters:
sessionId- unique session identifier- Returns:
- a
Unithat completes after the counter has been incremented
-
incrementDocumentsFailed
Increment the count of documents that failed processing for a session.Reactive semantics: executes on the default worker pool due to database access. Side effects: increments the
documentsFailedcounter in the session row.- Parameters:
sessionId- unique session identifier- Returns:
- a
Unithat completes after the counter has been incremented
-
incrementDocumentsSkipped
Increment the count of documents skipped (not processed) for a session.Reactive semantics: executes on the default worker pool due to database access. Side effects: increments the
documentsSkippedcounter in the session row.- Parameters:
sessionId- unique session identifier- Returns:
- a
Unithat completes after the counter has been incremented
-
addBytesProcessed
Add the number of processed bytes to the session total.Reactive semantics: executes on the default worker pool due to database access. Side effects: increments the
bytesProcessedcounter in the session row.- Parameters:
sessionId- unique session identifierbytes- number of bytes to add (must be non-negative)- Returns:
- a
Unithat completes after the counter has been updated
-