Struct unleash_api_client::client::Client
source · pub struct Client<F, C>{
pub http: HTTP<C>,
/* private fields */
}
Fields§
§http: HTTP<C>
Implementations§
source§impl<F, C> Client<F, C>where
F: EnumArray<CachedFeature> + Clone + Debug + DeserializeOwned + Serialize,
C: HttpClient + Default,
impl<F, C> Client<F, C>where
F: EnumArray<CachedFeature> + Clone + Debug + DeserializeOwned + Serialize,
C: HttpClient + Default,
sourcepub fn cached_state(&self) -> Guard<Option<Arc<CachedState<F>>>>
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.
sourcepub fn get_variant(&self, feature_enum: F, context: &Context) -> Variant
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.
sourcepub fn get_variant_str(&self, feature_name: &str, context: &Context) -> Variant
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.
pub fn is_enabled( &self, feature_enum: F, context: Option<&Context>, default: bool ) -> bool
pub fn is_enabled_str( &self, feature_name: &str, context: Option<&Context>, default: bool ) -> bool
sourcepub fn memoize(
&self,
features: Vec<Feature>
) -> Result<Option<Metrics>, Box<dyn Error + Send + Sync>>
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.
sourcepub async fn poll_for_updates(&self)
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().