Module: Kreuzberg::EnrichStatus
- Extended by:
- T::Helpers, T::Sig
- Included in:
- EnrichStatusCompleted, EnrichStatusFailed, EnrichStatusPending
- Defined in:
- lib/kreuzberg/native.rb
Overview
Async lifecycle status for an enrichment job.
Intended for use with any polling or event-driven pipeline that needs to track whether enrichment has completed, succeeded, or failed.
# Serialisation
Uses an internally-tagged ‘“status”` field with `snake_case` variants:
“‘json { “status”: “pending” } { “status”: “completed”, “result”: { … } } { “status”: “failed”, “error”: “text too large” } “`
“‘ use kreuzberg::enrichment::EnrichResult;
let s = EnrichStatus::Pending; let json = serde_json::to_value(&s).unwrap(); assert_eq!(json, “pending”);
let s = EnrichStatus::Completed { result: EnrichResult::default() }; let json = serde_json::to_value(&s).unwrap(); assert_eq!(json, “completed”); “‘
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
3958 3959 3960 3961 3962 3963 3964 3965 3966 |
# File 'lib/kreuzberg/native.rb', line 3958 def self.from_hash(hash) discriminator = hash[:status] || hash["status"] case discriminator when "pending" then EnrichStatusPending.from_hash(hash) when "completed" then EnrichStatusCompleted.from_hash(hash) when "failed" then EnrichStatusFailed.from_hash(hash) else raise "Unknown discriminator: #{discriminator}" end end |