pub struct FunctionRouter { /* private fields */ }Expand description
Routes and executes function calls with timeout, rate limiting, and observability.
Implementations§
Source§impl FunctionRouter
impl FunctionRouter
Sourcepub fn new(registry: Arc<FunctionRegistry>, db: Database) -> Self
pub fn new(registry: Arc<FunctionRegistry>, db: Database) -> Self
Create a new function router.
Sourcepub fn with_http_client(
registry: Arc<FunctionRegistry>,
db: Database,
http_client: CircuitBreakerClient,
) -> Self
pub fn with_http_client( registry: Arc<FunctionRegistry>, db: Database, http_client: CircuitBreakerClient, ) -> Self
Create a new function router with a custom HTTP client.
Sourcepub fn with_dispatch(
registry: Arc<FunctionRegistry>,
db: Database,
job_dispatcher: Option<Arc<dyn JobDispatch>>,
workflow_dispatcher: Option<Arc<dyn WorkflowDispatch>>,
) -> Self
pub fn with_dispatch( registry: Arc<FunctionRegistry>, db: Database, job_dispatcher: Option<Arc<dyn JobDispatch>>, workflow_dispatcher: Option<Arc<dyn WorkflowDispatch>>, ) -> Self
Create a router with dispatch capabilities.
Sourcepub fn with_dispatch_and_issuer(
registry: Arc<FunctionRegistry>,
db: Database,
job_dispatcher: Option<Arc<dyn JobDispatch>>,
workflow_dispatcher: Option<Arc<dyn WorkflowDispatch>>,
token_issuer: Option<Arc<dyn TokenIssuer>>,
) -> Self
pub fn with_dispatch_and_issuer( registry: Arc<FunctionRegistry>, db: Database, job_dispatcher: Option<Arc<dyn JobDispatch>>, workflow_dispatcher: Option<Arc<dyn WorkflowDispatch>>, token_issuer: Option<Arc<dyn TokenIssuer>>, ) -> Self
Create a router with dispatch and token issuer.
Sourcepub fn with_role_resolver(self, resolver: SharedRoleResolver) -> Self
pub fn with_role_resolver(self, resolver: SharedRoleResolver) -> Self
Set a custom role resolver for RBAC extension.
Sourcepub fn set_role_resolver(&mut self, resolver: SharedRoleResolver)
pub fn set_role_resolver(&mut self, resolver: SharedRoleResolver)
Set a custom role resolver (mutable reference version).
Sourcepub fn with_rate_limiter(
self,
rate_limiter: Arc<dyn RateLimiterBackend>,
) -> Self
pub fn with_rate_limiter( self, rate_limiter: Arc<dyn RateLimiterBackend>, ) -> Self
Override the default HybridRateLimiter with a custom backend
(e.g. crate::rate_limit::StrictRateLimiter for cluster-correct quotas).
Sourcepub fn set_rate_limiter(&mut self, rate_limiter: Arc<dyn RateLimiterBackend>)
pub fn set_rate_limiter(&mut self, rate_limiter: Arc<dyn RateLimiterBackend>)
Replace the rate-limiter backend (mutable variant for late binding).
Sourcepub fn with_token_issuer(self, issuer: Arc<dyn TokenIssuer>) -> Self
pub fn with_token_issuer(self, issuer: Arc<dyn TokenIssuer>) -> Self
Set the token issuer for this router (enables ctx.issue_token() in mutations).
Sourcepub fn with_token_ttl(self, ttl: AuthTokenTtl) -> Self
pub fn with_token_ttl(self, ttl: AuthTokenTtl) -> Self
Set the token TTL config for this router (configures ctx.issue_token_pair() durations).
Sourcepub fn set_token_ttl(&mut self, ttl: AuthTokenTtl)
pub fn set_token_ttl(&mut self, ttl: AuthTokenTtl)
Set the token TTL config (mutable reference version).
Sourcepub fn with_job_dispatcher(self, dispatcher: Arc<dyn JobDispatch>) -> Self
pub fn with_job_dispatcher(self, dispatcher: Arc<dyn JobDispatch>) -> Self
Set the job dispatcher for this router.
Sourcepub fn with_workflow_dispatcher(
self,
dispatcher: Arc<dyn WorkflowDispatch>,
) -> Self
pub fn with_workflow_dispatcher( self, dispatcher: Arc<dyn WorkflowDispatch>, ) -> Self
Set the workflow dispatcher for this router.
Sourcepub fn with_kv(self, kv: Arc<dyn KvHandle>) -> Self
pub fn with_kv(self, kv: Arc<dyn KvHandle>) -> Self
Attach a KV store handle so handlers can call ctx.kv().
Sourcepub fn set_kv(&mut self, kv: Arc<dyn KvHandle>)
pub fn set_kv(&mut self, kv: Arc<dyn KvHandle>)
Attach a KV store handle (mutable reference version).
Sourcepub fn with_default_timeout(self, timeout: Duration) -> Self
pub fn with_default_timeout(self, timeout: Duration) -> Self
Set the default timeout applied to all function calls.
Sourcepub fn set_max_jobs_per_request(&mut self, limit: usize)
pub fn set_max_jobs_per_request(&mut self, limit: usize)
Set the maximum number of jobs a single mutation may dispatch. A value of 0 disables the limit.
Sourcepub fn set_max_result_size_bytes(&mut self, limit: usize)
pub fn set_max_result_size_bytes(&mut self, limit: usize)
Set the maximum serialized response size in bytes. A value of 0 disables the limit.
Sourcepub async fn execute(
&self,
function_name: &str,
args: Value,
auth: AuthContext,
request: RequestMetadata,
) -> Result<Value>
pub async fn execute( &self, function_name: &str, args: Value, auth: AuthContext, request: RequestMetadata, ) -> Result<Value>
Execute a function call with timeout, observability, and signals emission.
Sourcepub fn function_info(&self, function_name: &str) -> Option<FunctionInfo>
pub fn function_info(&self, function_name: &str) -> Option<FunctionInfo>
Look up function metadata by name.
Sourcepub fn has_function(&self, function_name: &str) -> bool
pub fn has_function(&self, function_name: &str) -> bool
Check if a function exists.
Sourcepub fn get_function_kind(&self, function_name: &str) -> Option<FunctionKind>
pub fn get_function_kind(&self, function_name: &str) -> Option<FunctionKind>
Get the function kind by name.
Sourcepub fn function_infos(&self) -> Vec<FunctionInfo>
pub fn function_infos(&self) -> Vec<FunctionInfo>
Return info for all registered query and mutation functions.
Sourcepub fn cache(&self) -> Arc<QueryCacheCoordinator> ⓘ
pub fn cache(&self) -> Arc<QueryCacheCoordinator> ⓘ
Shared handle to the query cache coordinator (used to wire cluster invalidation).
pub async fn route( &self, function_name: &str, args: Value, auth: AuthContext, request: RequestMetadata, ) -> Result<RouteOutcome>
Auto Trait Implementations§
impl Freeze for FunctionRouter
impl !RefUnwindSafe for FunctionRouter
impl Send for FunctionRouter
impl Sync for FunctionRouter
impl Unpin for FunctionRouter
impl UnsafeUnpin for FunctionRouter
impl !UnwindSafe for FunctionRouter
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more