pub struct OrgControls { /* private fields */ }Expand description
Organization controls service
Manages org-level AI controls with YAML defaults and DB authoritative overrides. DB values override YAML defaults when both are present.
Implementations§
Source§impl OrgControls
impl OrgControls
Sourcepub fn new(yaml_config: OrgAiControlsConfig) -> OrgControls
pub fn new(yaml_config: OrgAiControlsConfig) -> OrgControls
Create a new org controls service with YAML defaults only
Sourcepub fn with_db_accessor(
yaml_config: OrgAiControlsConfig,
db_accessor: Box<dyn OrgControlsAccessor>,
) -> OrgControls
pub fn with_db_accessor( yaml_config: OrgAiControlsConfig, db_accessor: Box<dyn OrgControlsAccessor>, ) -> OrgControls
Create a new org controls service with YAML defaults and DB accessor
Sourcepub async fn load_org_config(
&self,
org_id: &str,
workspace_id: Option<&str>,
) -> Result<OrgAiControlsConfig, Error>
pub async fn load_org_config( &self, org_id: &str, workspace_id: Option<&str>, ) -> Result<OrgAiControlsConfig, Error>
Load org configuration (DB overrides YAML)
Sourcepub async fn check_budget(
&self,
org_id: &str,
workspace_id: Option<&str>,
estimated_tokens: u64,
) -> Result<BudgetCheckResult, Error>
pub async fn check_budget( &self, org_id: &str, workspace_id: Option<&str>, estimated_tokens: u64, ) -> Result<BudgetCheckResult, Error>
Check if budget allows the request
Sourcepub async fn check_rate_limit(
&self,
org_id: &str,
workspace_id: Option<&str>,
) -> Result<RateLimitCheckResult, Error>
pub async fn check_rate_limit( &self, org_id: &str, workspace_id: Option<&str>, ) -> Result<RateLimitCheckResult, Error>
Check if rate limit allows the request
Trait Implementations§
Source§impl Default for OrgControls
impl Default for OrgControls
Source§fn default() -> OrgControls
fn default() -> OrgControls
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OrgControls
impl !RefUnwindSafe for OrgControls
impl Send for OrgControls
impl Sync for OrgControls
impl Unpin for OrgControls
impl UnsafeUnpin for OrgControls
impl !UnwindSafe for OrgControls
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
Mutably borrows from an owned value. Read more
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>
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 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>
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