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 25, 2021
1 parent 04e9177 commit 67ed5d8
Show file tree
Hide file tree
Showing 2 changed files with 20 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>? = listOf()

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

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

override fun updateExperiments() {
fetchScope.launch {
fetchExperimentsOnThisThread()
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ permalink: /changelog/
* **feature-downloads**:
* 🚒 Bug fixed [issue #9964](https://github.com/mozilla-mobile/android-components/issues/9964) - Downloads notification strings are not localized.

* **service-nimbus**
* Added `getExperimentBranches` method to `Nimbus` for retrieving a list of experiment branches for a given experiment. [issue #9895](https://github.com/mozilla-mobile/android-components/issues/9895)

# 74.0.0

* [Commits](https://github.com/mozilla-mobile/android-components/compare/v73.0.0...v74.0.0)
Expand Down

0 comments on commit 67ed5d8

Please sign in to comment.