Skip to main content

FunctionRouter

Struct FunctionRouter 

Source
pub struct FunctionRouter { /* private fields */ }
Expand description

Routes and executes function calls with timeout, rate limiting, and observability.

Implementations§

Source§

impl FunctionRouter

Source

pub fn new(registry: Arc<FunctionRegistry>, db: Database) -> Self

Create a new function router.

Source

pub fn with_http_client( registry: Arc<FunctionRegistry>, db: Database, http_client: CircuitBreakerClient, ) -> Self

Create a new function router with a custom HTTP client.

Source

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.

Source

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.

Source

pub fn with_role_resolver(self, resolver: SharedRoleResolver) -> Self

Set a custom role resolver for RBAC extension.

Source

pub fn set_role_resolver(&mut self, resolver: SharedRoleResolver)

Set a custom role resolver (mutable reference version).

Source

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).

Source

pub fn set_rate_limiter(&mut self, rate_limiter: Arc<dyn RateLimiterBackend>)

Replace the rate-limiter backend (mutable variant for late binding).

Source

pub fn with_token_issuer(self, issuer: Arc<dyn TokenIssuer>) -> Self

Set the token issuer for this router (enables ctx.issue_token() in mutations).

Source

pub fn with_token_ttl(self, ttl: AuthTokenTtl) -> Self

Set the token TTL config for this router (configures ctx.issue_token_pair() durations).

Source

pub fn set_token_ttl(&mut self, ttl: AuthTokenTtl)

Set the token TTL config (mutable reference version).

Source

pub fn with_job_dispatcher(self, dispatcher: Arc<dyn JobDispatch>) -> Self

Set the job dispatcher for this router.

Source

pub fn with_workflow_dispatcher( self, dispatcher: Arc<dyn WorkflowDispatch>, ) -> Self

Set the workflow dispatcher for this router.

Source

pub fn with_kv(self, kv: Arc<dyn KvHandle>) -> Self

Attach a KV store handle so handlers can call ctx.kv().

Source

pub fn set_kv(&mut self, kv: Arc<dyn KvHandle>)

Attach a KV store handle (mutable reference version).

Source

pub fn with_default_timeout(self, timeout: Duration) -> Self

Set the default timeout applied to all function calls.

Source

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.

Source

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.

Source

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.

Source

pub fn function_info(&self, function_name: &str) -> Option<FunctionInfo>

Look up function metadata by name.

Source

pub fn has_function(&self, function_name: &str) -> bool

Check if a function exists.

Source

pub fn get_function_kind(&self, function_name: &str) -> Option<FunctionKind>

Get the function kind by name.

Source

pub fn function_infos(&self) -> Vec<FunctionInfo>

Return info for all registered query and mutation functions.

Source

pub fn cache(&self) -> Arc<QueryCacheCoordinator>

Shared handle to the query cache coordinator (used to wire cluster invalidation).

Source

pub async fn route( &self, function_name: &str, args: Value, auth: AuthContext, request: RequestMetadata, ) -> Result<RouteOutcome>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more