-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for persistent storage https://docs.statsig.com/server/concepts/persistent_assignment Kong: https://app.graphite.dev/github/pr/statsig-io/kong/2556 Docs: https://app.graphite.dev/github/pr/statsig-io/docs/1995
- Loading branch information
1 parent
896d795
commit 1af76f0
Showing
16 changed files
with
764 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.statsig.sdk | ||
|
||
import com.statsig.sdk.persistent_storage.StickyValues | ||
|
||
class ConfigEvaluation( | ||
var booleanValue: Boolean = false, | ||
var jsonValue: Any? = null, | ||
var ruleID: String = Const.EMPTY_STR, | ||
var groupName: String? = null, | ||
var secondaryExposures: ArrayList<Map<String, String>> = arrayListOf(), | ||
var undelegatedSecondaryExposures: ArrayList<Map<String, String>> = arrayListOf(), | ||
var explicitParameters: Array<String>? = null, | ||
var configDelegate: String? = null, | ||
var evaluationDetails: EvaluationDetails? = null, | ||
var isExperimentGroup: Boolean = false, | ||
) { | ||
internal var isDelegate: Boolean = false | ||
|
||
fun addSecondaryExposure(exposure: Map<String, String>) { | ||
secondaryExposures.add(exposure) | ||
if (!isDelegate) { | ||
undelegatedSecondaryExposures.add(exposure) | ||
} | ||
} | ||
|
||
// Used to save to PersistentStorage | ||
fun toStickyValues(): StickyValues { | ||
return StickyValues( | ||
value = this.booleanValue, | ||
jsonValue = this.jsonValue, | ||
ruleID = this.ruleID, | ||
groupName = this.groupName, | ||
secondaryExposures = this.secondaryExposures, | ||
explicitParameters = this.explicitParameters, | ||
configDelegate = this.configDelegate, | ||
undelegatedSecondaryExposures = this.undelegatedSecondaryExposures, | ||
time = this.evaluationDetails?.configSyncTime ?: Utils.getTimeInMillis(), | ||
) | ||
} | ||
|
||
companion object { | ||
fun fromStickyValues(stickyValues: StickyValues, initTime: Long): ConfigEvaluation { | ||
val evalDetail = EvaluationDetails( | ||
stickyValues.time, | ||
initTime, | ||
EvaluationReason.PERSISTED | ||
) | ||
return ConfigEvaluation( | ||
jsonValue = stickyValues.jsonValue, | ||
booleanValue = stickyValues.value, | ||
ruleID = stickyValues.ruleID, | ||
groupName = stickyValues.groupName, | ||
secondaryExposures = stickyValues.secondaryExposures, | ||
undelegatedSecondaryExposures = stickyValues.undelegatedSecondaryExposures, | ||
explicitParameters = stickyValues.explicitParameters, | ||
configDelegate = stickyValues.configDelegate, | ||
isExperimentGroup = true, | ||
evaluationDetails = evalDetail, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.