pub struct Client<F, C>{
    pub http: HTTP<C>,
    /* private fields */
}

Fields§

§http: HTTP<C>

Implementations§

source§

impl<F, C> Client<F, C>

source

pub fn cached_state(&self) -> Guard<Option<Arc<CachedState<F>>>>

The cached state can be accessed. It may be uninitialised, and represents a point in time snapshot: subsequent calls may have wound the metrics back, entirely lost string features etc.

source

pub fn get_variant(&self, feature_enum: F, context: &Context) -> Variant

Determine what variant (if any) of the feature the given context is selected for. This is a consistent selection within a feature only

  • across different features with identical variant definitions, different variant selection will take place.

The key used to hash is the first of the username, sessionid, the host address, or a random string per call to get_variant.

source

pub fn get_variant_str(&self, feature_name: &str, context: &Context) -> Variant

Determine what variant (if any) of the feature the given context is selected for. This is a consistent selection within a feature only

  • across different features with identical variant definitions, different variant selection will take place.

The key used to hash is the first of the username, sessionid, the host address, or a random string per call to get_variant.

source

pub fn is_enabled( &self, feature_enum: F, context: Option<&Context>, default: bool ) -> bool

source

pub fn is_enabled_str( &self, feature_name: &str, context: Option<&Context>, default: bool ) -> bool

source

pub fn memoize( &self, features: Vec<Feature> ) -> Result<Option<Metrics>, Box<dyn Error + Send + Sync>>

Memoize new features into the cached state

Interior mutability is used, via the arc-swap crate.

Note that this is primarily public to facilitate benchmarking; poll_for_updates is the usual way in which memoize will be called.

source

pub async fn poll_for_updates(&self)

Query the API endpoint for features and push metrics

Immediately and then every self.interval milliseconds the API server is queryed for features and the previous cycles metrics are uploaded.

May be dropped, or will terminate at the next polling cycle after stop_poll is called().

source

pub async fn register( &self ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>

Register this client with the API endpoint.

source

pub async fn stop_poll(&self)

stop the poll_for_updates() function.

If poll is not running, will wait-loop until poll_for_updates is running, then signal it to stop, then return. Will wait for ever if poll_for_updates never starts running.

Auto Trait Implementations§

§

impl<F, C> !Freeze for Client<F, C>

§

impl<F, C> !RefUnwindSafe for Client<F, C>

§

impl<F, C> Send for Client<F, C>

§

impl<F, C> Sync for Client<F, C>

§

impl<F, C> Unpin for Client<F, C>
where C: Unpin, <C as HttpClient>::HeaderName: Unpin,

§

impl<F, C> !UnwindSafe for Client<F, C>

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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