Skip to main content

AkribesClientBuilder

Struct AkribesClientBuilder 

Source
pub struct AkribesClientBuilder { /* private fields */ }

Implementations§

Source§

impl AkribesClientBuilder

Source

pub fn project_id(self, project_id: i64) -> Self

Set the project ID. Required for project-scoped operations (scripts, executions, etc.). Omit for global-only usage (list_projects, etc.).

Source

pub fn name(self, name: impl Into<String>) -> Self

Client display name (default: "rust-sdk").

Source

pub fn id(self, id: impl Into<String>) -> Self

Client ID (default: random UUID v4).

Source

pub fn token(self, token: impl Into<String>) -> Self

Initial authentication token. Either:

  • a service token (the secret part of AKRIBES_SERVICE_TOKEN_<NAME>=<scope>:<secret>), or
  • a scoped token of the form akribes_tk_<...> (legacy aura_tk_<...> still accepted) minted via crate::sub::tokens::TokensClient::mint.
Source

pub fn on_behalf_of(self, email: impl Into<String>) -> Self

Set the X-Akribes-User header sent on every outbound request.

Used by the server for metrics attribution when a backend (typically holding a service token) acts on behalf of an end user. Advisory only — does not grant any permission. Authorization remains based on the bearer token’s scope.

Mirrors the TS AkribesClientOptions.onBehalfOf and Python AkribesClient(on_behalf_of=...) knobs. Use AkribesClient::set_on_behalf_of to update the value at runtime.

let client = AkribesClient::builder("http://localhost:3001")
    .project_id(2)
    .token(std::env::var("AKRIBES_SERVICE_TOKEN").unwrap())
    .on_behalf_of("alice@acme.com")
    .build();
Source

pub fn http_client(self, client: Client) -> Self

Use a pre-configured reqwest::Client so multiple AkribesClients can share a connection pool, proxy settings, or TLS configuration.

If not called, a default reqwest::Client is created with a 60s request timeout and a 10s connect timeout.

Source

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

Override the deadline documents().ingest() waits for a still-converting blob before surfacing AkribesError::Transient.

Resolution order at build time:

  1. This builder param if set.
  2. AKRIBES_SDK_INGEST_TIMEOUT_SECS env var (parsed as u64 seconds; 0 and unparseable values are ignored).
  3. [DEFAULT_INGEST_POLL_TIMEOUT_SECS] (300 s).

Setting this to a very short duration is occasionally useful in tests that want to assert the timeout path. Setting it absurdly long (hours) just shifts the failure mode — the server has its own conversion timeouts.

Source

pub fn build(self) -> AkribesClient

Build the client.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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<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