pub struct UserContext { /* private fields */ }Implementations§
Source§impl UserContext
impl UserContext
pub fn try_local_lock( &self, key: &str, timeout_millis: u64, expire_millis: u64, ) -> bool
pub fn unlock_local(&self, key: &str)
Sourcepub async fn try_remote_lock(
&self,
key: &str,
timeout_millis: u64,
expire_millis: u64,
) -> bool
pub async fn try_remote_lock( &self, key: &str, timeout_millis: u64, expire_millis: u64, ) -> bool
Attempts to acquire a provider-backed distributed lock.
A missing provider remains a no-op success, matching the optional
Remote Lock boundary in the other TeaQL runtimes. Install an
Arc<dyn RemoteLockProvider> resource to enable distributed exclusion.
Sourcepub async fn unlock_remote(&self, key: &str) -> bool
pub async fn unlock_remote(&self, key: &str) -> bool
Releases a distributed lock only when this context still owns it.
Source§impl UserContext
impl UserContext
pub fn with_sql_log_options(self, options: SqlLogOptions) -> Self
pub fn set_sql_log_options(&mut self, options: SqlLogOptions)
pub fn enable_select_sql_log(&mut self)
pub fn enable_mutation_sql_log(&mut self)
pub fn disable_select_sql_log(&mut self)
pub fn disable_mutation_sql_log(&mut self)
pub fn enable_all_sql_log(&mut self)
pub fn disable_sql_log(&mut self)
pub fn sql_log_options(&self) -> SqlLogOptions
pub fn sql_logs(&self) -> Vec<SqlLogEntry>
pub fn clear_sql_logs(&self)
Source§impl UserContext
impl UserContext
pub fn set_continuous_page_cursor_store( &mut self, store: Arc<dyn ContinuousPageCursorStore>, )
pub fn continuous_page_plan(&self) -> Option<String>
pub fn continuous_page_cursor_id(&self) -> Option<String>
pub fn set_id_set_store(&mut self, store: Arc<dyn IdSetStore>)
pub fn id_set_plan(&self) -> Option<String>
pub fn id_set_count(&self) -> Option<u64>
Source§impl UserContext
impl UserContext
Sourcepub async fn execute_in_transaction<'context, E, T, F>(
&'context self,
operation: F,
) -> Result<T, RuntimeError>where
E: TransactionExecutor + Send + Sync + 'static,
for<'transaction> E::Tx<'transaction>: Send + Sync,
F: for<'scope> FnOnce(&'scope TransactionScope<'context, E>) -> Pin<Box<dyn Future<Output = Result<T, RuntimeError>> + 'scope>>,
pub async fn execute_in_transaction<'context, E, T, F>(
&'context self,
operation: F,
) -> Result<T, RuntimeError>where
E: TransactionExecutor + Send + Sync + 'static,
for<'transaction> E::Tx<'transaction>: Send + Sync,
F: for<'scope> FnOnce(&'scope TransactionScope<'context, E>) -> Pin<Box<dyn Future<Output = Result<T, RuntimeError>> + 'scope>>,
Execute work against one typed transaction, committing on success and rolling back on error.
The callback receives a TransactionScope; using the surrounding
UserContext inside the callback would intentionally execute outside the
transaction.
Source§impl UserContext
impl UserContext
pub fn new() -> Self
pub fn with_active_root(self, entity_type: impl Into<String>, id: u64) -> Self
pub fn require_active_root( &self, expected_entity_type: &str, ) -> Result<&ContextEntityRef, ContextRootError>
pub fn with_runtime_telemetry( self, telemetry: Arc<dyn RuntimeTelemetry>, ) -> Self
pub fn set_runtime_telemetry(&mut self, telemetry: Arc<dyn RuntimeTelemetry>)
pub fn runtime_telemetry(&self) -> &Arc<dyn RuntimeTelemetry> ⓘ
pub fn start_runtime_operation( &self, operation: RuntimeOperation, ) -> FailOpenRuntimeTelemetryScope
pub fn user_identifier(&self) -> Option<&str>
pub fn set_user_identifier(&mut self, user_identifier: impl Into<String>)
pub fn with_user_identifier(self, user_identifier: impl Into<String>) -> Self
pub fn set_user_identifier_option(&mut self, user_identifier: Option<String>)
pub fn with_user_identifier_option( self, user_identifier: Option<String>, ) -> Self
pub fn timezone(&self) -> Option<&str>
pub fn set_timezone(&mut self, timezone: impl Into<String>)
pub fn with_timezone(self, timezone: impl Into<String>) -> Self
pub fn trace_id(&self) -> &str
pub fn set_trace_id(&mut self, trace_id: impl Into<String>)
pub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
pub fn with_module(self, module: RuntimeModule) -> Self
pub fn entity_runtime_state(&self) -> EntityRuntimeState
pub fn initial_graphs(&self) -> &[GraphNode]
pub fn set_initial_graphs(&mut self, graphs: Vec<GraphNode>)
pub fn root_graphs(&self) -> &[GraphNode]
pub fn set_root_graphs(&mut self, graphs: Vec<GraphNode>)
pub fn with_metadata(self, metadata: impl MetadataStore + 'static) -> Self
pub fn set_metadata(&mut self, metadata: impl MetadataStore + 'static)
pub fn with_entity_registry( self, registry: impl EntityRegistry + 'static, ) -> Self
pub fn set_entity_registry(&mut self, registry: impl EntityRegistry + 'static)
pub fn set_entity_graph_decoder_registry( &mut self, registry: InMemoryEntityGraphDecoderRegistry, )
pub fn with_entity_data_service_behavior_registry( self, registry: impl EntityDataServiceBehaviorRegistry + 'static, ) -> Self
pub fn set_entity_data_service_behavior_registry( &mut self, registry: impl EntityDataServiceBehaviorRegistry + 'static, )
pub fn with_request_policy(self, policy: impl RequestPolicy + 'static) -> Self
pub fn set_request_policy(&mut self, policy: impl RequestPolicy + 'static)
pub fn clear_request_policy(&mut self)
pub fn with_checker_registry( self, registry: impl CheckerRegistry + 'static, ) -> Self
pub fn set_checker_registry(&mut self, registry: impl CheckerRegistry + 'static)
pub fn with_custom_event_sink( self, sink: impl SafeAuditEventSink + 'static, ) -> Self
pub fn set_custom_event_sink(&mut self, sink: impl SafeAuditEventSink + 'static)
pub fn with_internal_id_generator( self, generator: impl InternalIdGenerator + 'static, ) -> Self
pub fn set_internal_id_generator( &mut self, generator: impl InternalIdGenerator + 'static, )
pub fn with_schema_provider( self, provider: impl SchemaProvider + 'static, ) -> Self
pub fn set_schema_provider(&mut self, provider: impl SchemaProvider + 'static)
pub async fn ensure_schema(&self) -> Result<(), RuntimeError>
pub fn with_language(self, language: Language) -> Self
pub fn set_language(&mut self, language: Language)
pub fn with_i18n_catalog(self, catalog: Arc<I18nCatalog>) -> Self
pub fn set_i18n_catalog(&mut self, catalog: Arc<I18nCatalog>)
pub fn language(&self) -> Language
pub fn set_language_code(&mut self, code: &str) -> Result<(), RuntimeError>
pub fn set_locale_code(&mut self, code: &str) -> Result<(), RuntimeError>
pub fn generate_id(&self, entity: &str) -> Result<Option<u64>, RuntimeError>
pub fn next_id(&self, entity: &str) -> Result<u64, RuntimeError>
pub fn entity(&self, name: &str) -> Option<&EntityDescriptor>
pub fn all_entities(&self) -> Vec<&EntityDescriptor>
pub fn require_entity( &self, name: &str, ) -> Result<&EntityDescriptor, RuntimeError>
pub fn insert_resource<T>(&mut self, resource: T)
pub fn get_resource<T>(&self) -> Option<&T>
pub fn require_resource<T>(&self) -> Result<&T, ContextError>
pub fn insert_named_resource<T>(&mut self, name: impl Into<String>, resource: T)
pub fn get_named_resource<T>(&self, name: &str) -> Option<&T>
pub fn require_named_resource<T>(&self, name: &str) -> Result<&T, ContextError>
pub fn put_local(&mut self, key: impl Into<String>, value: impl Into<Value>)
pub fn local(&self, key: &str) -> Option<&Value>
pub fn remove_local(&mut self, key: &str) -> Option<Value>
pub fn has_entity_data_service(&self, entity: &str) -> bool
pub fn entity_data_service_behavior( &self, entity: &str, ) -> Option<Arc<dyn EntityDataServiceBehavior>>
pub fn has_checker(&self, entity: &str) -> bool
Sourcepub fn fix_time(&self) -> Timestamp
pub fn fix_time(&self) -> Timestamp
One deterministic clock value for every Fix executed by the current graph save. The task-local scope keeps concurrent saves on one context isolated; standalone checker calls receive their own current value.
pub fn record_fix_evidence(&self, evidence: FixEvidence)
pub fn last_fix_evidence(&self) -> Vec<FixEvidence>
pub fn check_and_fix_values( &self, entity: &str, values: &mut EntityValues, ) -> Result<(), RuntimeError>
pub fn check_and_fix_values_at( &self, entity: &str, values: &mut EntityValues, location: &ObjectLocation, ) -> Result<(), RuntimeError>
pub fn translate_check_results(&self, results: &mut CheckResults)
pub fn send_event(&self, event: RawAuditEvent) -> Result<(), RuntimeError>
pub async fn get_in_store(&self, key: &str) -> Option<Value>
pub async fn put_in_store( &self, key: &str, value: impl Into<Value>, timeout_seconds: Option<u64>, )
pub async fn clear_in_store(&self, key: &str)
Source§impl UserContext
impl UserContext
pub fn entity_data_service<E>( &self, entity: impl Into<String>, ) -> Result<EntityDataService<'_, E>, ContextError>
Sourcepub fn register_executor<E>(&mut self, executor: E)where
E: QueryExecutor + MutationExecutor + TransactionExecutor + Send + Sync + 'static,
for<'tx> <E as TransactionExecutor>::Tx<'tx>: Send + Sync,
pub fn register_executor<E>(&mut self, executor: E)where
E: QueryExecutor + MutationExecutor + TransactionExecutor + Send + Sync + 'static,
for<'tx> <E as TransactionExecutor>::Tx<'tx>: Send + Sync,
Register a data-service executor and automatically set up the
type-erased graph saver so that
Audited::save works.