Skip to content

Commit

Permalink
Issue mozilla-mobile#9895: Expose getExperimentBranches in NimbusClie…
Browse files Browse the repository at this point in the history
…ntInterface
  • Loading branch information
gabrielluong committed Mar 15, 2021
1 parent 0526597 commit e27e896
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

@file:Suppress("TooManyFunctions")

package mozilla.components.service.nimbus

import android.content.Context
Expand All @@ -26,6 +28,7 @@ import mozilla.components.support.base.utils.NamedThreadFactory
import mozilla.components.support.locale.getLocaleTag
import org.mozilla.experiments.nimbus.AppContext
import org.mozilla.experiments.nimbus.AvailableRandomizationUnits
import org.mozilla.experiments.nimbus.Branch
import org.mozilla.experiments.nimbus.EnrolledExperiment
import org.mozilla.experiments.nimbus.EnrollmentChangeEvent
import org.mozilla.experiments.nimbus.EnrollmentChangeEventType
Expand Down Expand Up @@ -63,6 +66,15 @@ interface NimbusApi : Observable<NimbusApi.Observer> {
@AnyThread
fun getExperimentBranch(experimentId: String): String? = null

/**
* Get the list of experiment branches for the given experiment
*
* @param experimentId The string experiment-id or "slug" for which to retrieve the branch
*
* @return A list of [Branch]s
*/
fun getExperimentBranches(experimentId: String): List<Branch>

/**
* Refreshes the experiments from the endpoint. Should be called at least once after
* initialization
Expand Down Expand Up @@ -252,6 +264,10 @@ class Nimbus(
return nimbus.getExperimentBranch(experimentId)
}

@WorkerThread
override fun getExperimentBranches(experimentId: String): List<Branch> =
nimbus.getExperimentBranches(experimentId)

override fun updateExperiments() {
fetchScope.launch {
fetchExperimentsOnThisThread()
Expand Down

0 comments on commit e27e896

Please sign in to comment.