pub struct SourceDefinition {
pub name: String,
pub schedule: String,
pub cursor: Option<String>,
pub function: String,
pub enabled: bool,
pub options: Value,
pub run_as: Option<RunAs>,
}Expand description
A scheduled ingress Source — the dual of an
ObserverDefinition.
An observer is egress (“a database change → tell the world”); a source is
ingress (“on a schedule → fetch the world → write the database via mutations”,
resuming from a durable cursor). The function runs on the cron schedule;
authoring is metadata-only — the body is a Deno function (Model B) or a built-in
native PullSource (Model A).
This desugars to a cron:<schedule> scheduling of function, bound to a durable
cursor named cursor_name — sugar over the existing cron
trigger, not a new trigger kind.
§Example
use fraiseql_core::schema::SourceDefinition;
let source = SourceDefinition::new("orders", "*/5 * * * *", "pollOrders");
assert_eq!(source.cursor_name(), "orders"); // defaults to the source name
assert!(source.enabled);Fields§
§name: StringSource name (unique) — the durable-cursor row and the advisory-lease key.
schedule: StringPOSIX cron expression the source polls on (e.g. "*/5 * * * *").
cursor: Option<String>The durable cursor this source advances. Defaults to name
when absent, so most sources need not set it.
function: StringThe bound handler: a Deno function name (Model B) or a built-in native
PullSource name (Model A).
enabled: boolWhether the source is enabled. A disabled source is compiled but not
scheduled. Defaults to true.
options: ValueConnector-specific options handed to the source, opaque to the framework.
run_as: Option<RunAs>The authority this source’s background mutations run under (#573) — its
run_as ceiling. Absent ⇒ fail-closed: the source runs with no
roles/scopes/tenant and can write nothing. See identity.
Implementations§
Source§impl SourceDefinition
impl SourceDefinition
Sourcepub fn new(
name: impl Into<String>,
schedule: impl Into<String>,
function: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, schedule: impl Into<String>, function: impl Into<String>, ) -> Self
Create a source with the required fields; cursor defaults to the name,
enabled to true, and options to null.
Sourcepub fn cursor_name(&self) -> &str
pub fn cursor_name(&self) -> &str
Sourcepub fn with_cursor(self, cursor: impl Into<String>) -> Self
pub fn with_cursor(self, cursor: impl Into<String>) -> Self
Set an explicit cursor name (distinct from the source name).
Sourcepub fn with_options(self, options: Value) -> Self
pub fn with_options(self, options: Value) -> Self
Set connector options.
Sourcepub fn with_run_as(self, run_as: RunAs) -> Self
pub fn with_run_as(self, run_as: RunAs) -> Self
Set the run_as authority ceiling (#573).
Sourcepub fn identity(&self, request_id: impl Into<String>) -> SecurityContext
pub fn identity(&self, request_id: impl Into<String>) -> SecurityContext
The background SecurityContext this
source’s mutations run under (#573).
Built from run_as via
SecurityContext::system_job;
absent run_as yields a fail-closed identity (no roles, no scopes, no
tenant → every authz/RLS decision denies). request_id correlates one firing
of the source (typically its per-fire idempotency token).
Sourcepub fn cron_trigger(&self) -> String
pub fn cron_trigger(&self) -> String
The cron:<schedule> trigger type this source desugars to — the sugar-over-
cron binding. The runtime schedules function
on it.
Trait Implementations§
Source§impl Clone for SourceDefinition
impl Clone for SourceDefinition
Source§fn clone(&self) -> SourceDefinition
fn clone(&self) -> SourceDefinition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SourceDefinition
impl Debug for SourceDefinition
Source§impl<'de> Deserialize<'de> for SourceDefinition
impl<'de> Deserialize<'de> for SourceDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SourceDefinition
Source§impl PartialEq for SourceDefinition
impl PartialEq for SourceDefinition
Source§impl Serialize for SourceDefinition
impl Serialize for SourceDefinition
impl StructuralPartialEq for SourceDefinition
Auto Trait Implementations§
impl Freeze for SourceDefinition
impl RefUnwindSafe for SourceDefinition
impl Send for SourceDefinition
impl Sync for SourceDefinition
impl Unpin for SourceDefinition
impl UnsafeUnpin for SourceDefinition
impl UnwindSafe for SourceDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.