nimbus::stateful::nimbus_client

Struct NimbusClient

source
pub struct NimbusClient { /* private fields */ }
Expand description

Nimbus is the main struct representing the experiments state It should hold all the information needed to communicate a specific user’s experimentation status

Implementations§

source§

impl NimbusClient

source

pub fn new<P: Into<PathBuf>>( app_context: AppContext, recorded_context: Option<Arc<dyn RecordedContext>>, coenrolling_feature_ids: Vec<String>, db_path: P, config: Option<RemoteSettingsConfig>, metrics_handler: Box<dyn MetricsHandler>, ) -> Result<Self>

source

pub fn with_targeting_attributes( &mut self, targeting_attributes: TargetingAttributes, )

source

pub fn get_targeting_attributes(&self) -> TargetingAttributes

source

pub fn initialize(&self) -> Result<()>

source

pub fn get_enrollment_by_feature( &self, feature_id: String, ) -> Result<Option<EnrolledFeature>>

source

pub fn get_experiment_branch(&self, slug: String) -> Result<Option<String>>

source

pub fn get_feature_config_variables( &self, feature_id: String, ) -> Result<Option<String>>

source

pub fn get_experiment_branches( &self, slug: String, ) -> Result<Vec<ExperimentBranch>>

source

pub fn get_global_user_participation(&self) -> Result<bool>

source

pub fn set_global_user_participation( &self, user_participating: bool, ) -> Result<Vec<EnrollmentChangeEvent>>

source

pub fn get_active_experiments(&self) -> Result<Vec<EnrolledExperiment>>

source

pub fn get_all_experiments(&self) -> Result<Vec<Experiment>>

source

pub fn get_available_experiments(&self) -> Result<Vec<AvailableExperiment>>

source

pub fn opt_in_with_branch( &self, experiment_slug: String, branch: String, ) -> Result<Vec<EnrollmentChangeEvent>>

source

pub fn opt_out( &self, experiment_slug: String, ) -> Result<Vec<EnrollmentChangeEvent>>

source

pub fn fetch_experiments(&self) -> Result<()>

source

pub fn set_fetch_enabled(&self, allow: bool) -> Result<()>

source

pub fn apply_pending_experiments(&self) -> Result<Vec<EnrollmentChangeEvent>>

source

pub fn set_experiments_locally(&self, experiments_json: String) -> Result<()>

source

pub fn reset_enrollments(&self) -> Result<()>

Reset all enrollments and experiments in the database.

This should only be used in testing.

source

pub fn reset_telemetry_identifiers(&self) -> Result<Vec<EnrollmentChangeEvent>>

Reset internal state in response to application-level telemetry reset.

When the user resets their telemetry state in the consuming application, we need learn the new values of any external randomization units, and we need to reset any unique identifiers used internally by the SDK. If we don’t then we risk accidentally tracking across the telemetry reset, since we could use Nimbus metrics to link their pings from before and after the reset.

source

pub fn nimbus_id(&self) -> Result<Uuid>

source

pub fn set_nimbus_id(&self, uuid: &Uuid) -> Result<()>

source

pub fn create_targeting_helper( &self, additional_context: Option<Map<String, Value>>, ) -> Result<Arc<NimbusTargetingHelper>>

source

pub fn create_targeting_helper_with_context( &self, context: Value, ) -> Arc<NimbusTargetingHelper>

source

pub fn create_string_helper( &self, additional_context: Option<Map<String, Value>>, ) -> Result<Arc<NimbusStringHelper>>

source

pub fn record_event(&self, event_id: String, count: i64) -> Result<()>

Records an event for the purposes of behavioral targeting.

This function is used to record and persist data used for the behavioral targeting such as “core-active” user targeting.

source

pub fn record_past_event( &self, event_id: String, seconds_ago: i64, count: i64, ) -> Result<()>

Records an event for the purposes of behavioral targeting.

This differs from the record_event method in that the event is recorded as if it were recorded seconds_ago in the past. This makes it very useful for testing.

source

pub fn advance_event_time(&self, by_seconds: i64) -> Result<()>

Advances the event store’s concept of now artificially.

This works alongside record_event and record_past_event for testing purposes.

source

pub fn clear_events(&self) -> Result<()>

Clear all events in the Nimbus event store.

This should only be used in testing or cases where the previous event store is no longer viable.

source

pub fn event_store(&self) -> Arc<Mutex<EventStore>>

source

pub fn dump_state_to_log(&self) -> Result<()>

source§

impl NimbusClient

source

pub fn set_install_time(&mut self, then: DateTime<Utc>)

source

pub fn set_update_time(&mut self, then: DateTime<Utc>)

source§

impl NimbusClient

source

pub fn record_feature_exposure(&self, feature_id: String, slug: Option<String>)

source

pub fn record_malformed_feature_config( &self, feature_id: String, part_id: String, )

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.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. 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

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T