pub struct Projector<'a> { /* private fields */ }Expand description
Copies journal entries into a separate graph store in journal order, idempotently, and records per actor the last projected position in the target store.
Entry graphs are written with one insert per entry, in position order. When a state source
is configured (the graph side of a journal store that keeps current state, such as a
tiramemsu shard), the actor’s current-state graph is then brought to the source’s content by
a difference (removals and insertions, never a clear), and finally the position is recorded
as <actor> vt:projectedPosition n in the graph vocab::PROJECTION_GRAPH.
Every write is idempotent for entries without blank nodes, so a run interrupted at any point (the target unreachable, the process stopped) is completed by running again: entries after the recorded position are written again and change nothing they had already written.
Implementations§
Source§impl<'a> Projector<'a>
impl<'a> Projector<'a>
Sourcepub fn new(journal: &'a dyn JournalStore, target: &'a dyn GraphStore) -> Self
pub fn new(journal: &'a dyn JournalStore, target: &'a dyn GraphStore) -> Self
A projector from journal into target.
Sourcepub fn with_state_source(self, source: &'a dyn GraphStore) -> Self
pub fn with_state_source(self, source: &'a dyn GraphStore) -> Self
This projector also copying each actor’s current-state graph from source.
Sourcepub fn projected_position(
&self,
actor: &NamedNode,
) -> Result<Position, StoreError>
pub fn projected_position( &self, actor: &NamedNode, ) -> Result<Position, StoreError>
The last position of actor recorded in the target, 0 when none.
§Errors
The errors of GraphStore::query.
Sourcepub fn project_actor(
&self,
actor: &NamedNode,
) -> Result<ProjectionReport, StoreError>
pub fn project_actor( &self, actor: &NamedNode, ) -> Result<ProjectionReport, StoreError>
Projects the entries of actor after its recorded position, then its state, then
records the new position.
§Errors
The errors of the journal read and of the graph store writes. Nothing already written needs undoing: running again completes the projection.
Sourcepub fn project_all(&self) -> Result<Vec<ProjectionReport>, StoreError>
pub fn project_all(&self) -> Result<Vec<ProjectionReport>, StoreError>
Projects every actor of the journal store.
§Errors
The first error of Projector::project_actor; actors before it stay projected.