Skip to main content

SofRunner

Trait SofRunner 

Source
pub trait SofRunner: Send + Sync {
    // Required methods
    fn run_view<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
        view_definition: Value,
        filters: ViewFilters,
    ) -> Pin<Box<dyn Future<Output = Result<RowStream, SofError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn runner_name(&self) -> &'static str;
}
Expand description

Abstraction over in-process and in-DB SQL-on-FHIR execution strategies.

§Object safety

SofRunner is object-safe and intended for use as Arc<dyn SofRunner>. The [run_view] method returns a heap-allocated RowStream to avoid associated types that would break object safety.

§Threading

Implementors must be Send + Sync so that the runner can be stored in AppState and shared across request tasks.

Required Methods§

Source

fn run_view<'life0, 'life1, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, view_definition: Value, filters: ViewFilters, ) -> Pin<Box<dyn Future<Output = Result<RowStream, SofError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a ViewDefinition and return a stream of output rows.

§Arguments
  • tenant — The tenant context; all resource access is scoped to this tenant.
  • view_definition — The raw ViewDefinition JSON (any FHIR version).
  • filters — Optional filters (patient, group, since, limit).
§Returns

A RowStream that yields one flat JSON object per output row. The stream may be infinite in theory; callers should honour the filters.limit cap or impose their own.

§Errors

Returns SofError::Uncompilable synchronously (before the stream is polled) when this runner cannot handle the given ViewDefinition. The handler layer must catch this and either fall back to the in-process runner or return 422.

Source

fn runner_name(&self) -> &'static str

Returns a human-readable name for this runner (used in logs and diagnostics).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§